diff options
author | Daniel Gerhardt <code@dgerhardt.net> | 2015-06-04 21:08:35 +0200 |
---|---|---|
committer | Daniel Gerhardt <code@dgerhardt.net> | 2015-06-05 17:00:19 +0200 |
commit | 7f3eb42f4ec90315062e5ba08a0f48e5a21ec360 (patch) | |
tree | f6152d2b2ed7f4e58b1b71d1f81fb151dc3a5702 /app/models/project_services/issue_tracker_service.rb | |
parent | bedc66eb0407aa36127367f53f76944ebb98f5a6 (diff) | |
download | gitlab-ce-7f3eb42f4ec90315062e5ba08a0f48e5a21ec360.tar.gz |
Fix external issue tracker hook/test for HTTPS URLsdgerhardt/gitlab-ce-fix-ext-issue-tracker-hook
If HTTPS was used for 'project_url', an error was raised because a HTTP
connection was established to the default HTTPS port.
The code has been corrected and simplified by using HTTParty.
Additionally, the request now is made directly to the 'project_url'
instead of the extracted root path.
Diffstat (limited to 'app/models/project_services/issue_tracker_service.rb')
-rw-r--r-- | app/models/project_services/issue_tracker_service.rb | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb index c8ab9d63b74..936e574cccd 100644 --- a/app/models/project_services/issue_tracker_service.rb +++ b/app/models/project_services/issue_tracker_service.rb @@ -81,18 +81,13 @@ class IssueTrackerService < Service result = false begin - url = URI.parse(self.project_url) + response = HTTParty.head(self.project_url, verify: true) - if url.host && url.port - http = Net::HTTP.start(url.host, url.port, { open_timeout: 5, read_timeout: 5 }) - response = http.head("/") - - if response - message = "#{self.type} received response #{response.code} when attempting to connect to #{self.project_url}" - result = true - end + if response + message = "#{self.type} received response #{response.code} when attempting to connect to #{self.project_url}" + result = true end - rescue Timeout::Error, SocketError, Errno::ECONNRESET, Errno::ECONNREFUSED => error + rescue HTTParty::Error, Timeout::Error, SocketError, Errno::ECONNRESET, Errno::ECONNREFUSED => error message = "#{self.type} had an error when trying to connect to #{self.project_url}: #{error.message}" end Rails.logger.info(message) |