Fix external issue tracker hook/test for HTTPS URLs
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.
This commit is contained in:
parent
bedc66eb04
commit
7f3eb42f4e
|
@ -1,6 +1,7 @@
|
|||
Please view this file on the master branch, on stable branches it's out of date.
|
||||
|
||||
v 7.12.0 (unreleased)
|
||||
- Fix external issue tracker hook/test for HTTPS URLs (Daniel Gerhardt)
|
||||
- Don't notify users mentioned in code blocks or blockquotes.
|
||||
- Omit link to generate labels if user does not have access to create them (Stan Hu)
|
||||
- Disable changing of the source branch in merge request update API (Stan Hu)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue