Merge branch 'fix-ext-issue-tracker-hook' into 'master'
Fix external issue tracker hook/test for HTTPS URLs If HTTPS was used for the 'project_url' of an external issue tracker, 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. ## The bug is reproducible on gitlab.com 1. Set up a new external issue service (I used Redmine) 2. Set the project URL to 'http://example.com/redmine/projects/x' and click on 'Test settings' => Ok 3. Now set the URL to 'https://example.com/redmine/projects/x' and test it again => 500 ## What is actually happening? Web servers behave differently when a non-SSL connection is established to a SSL port: - Nginx / Apache 2.4: Status code 400 - Apache 2.2: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">... (no status code line is sent) - example.com: Empty response, no status code line ## Relevant log entries ``` 2015-06-04T11:10:47.972Z 16785 TID-exfks WARN: {"retry"=>true, "queue"=>"project_web_hook", "class"=>"ProjectServiceWorker", "args"=>[...], "error_message"=>"wrong status line: \"<!DOCTYPE HTML PUBLIC \\\"-//IETF//DTD HTML 2.0//EN\\\">\"", "error_class"=>"Net::HTTPBadResponse", ...} 2015-06-04T11:10:47.972Z 16785 TID-exfks WARN: wrong status line: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">" 2015-06-04T11:10:47.972Z 16785 TID-exfks WARN: /usr/lib/ruby/2.1.0/net/http/response.rb:41:in `read_status_line' [...] /home/git/gitlab-7.11.4/app/models/project_services/issue_tracker_service.rb:88:in `execute' /home/git/gitlab-7.11.4/app/workers/project_service_worker.rb:8:in `perform' [...] ``` See merge request !767
This commit is contained in:
commit
6c7131b469
2 changed files with 6 additions and 10 deletions
|
@ -13,6 +13,7 @@ v 7.12.0 (unreleased)
|
|||
- Fix timeout when rendering file with thousands of lines.
|
||||
- Add "Remember me" checkbox to LDAP signin form.
|
||||
- Add session expiration delay configuration through UI application settings
|
||||
- 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)
|
||||
- Show warning when a comment will add 10 or more people to the discussion.
|
||||
|
|
|
@ -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 a new issue