Fix ipv6 support

There is issue with ipv6 where address has to be in brackets, this causes the
underlying ruby TCPSocket to fail. Net::HTTP.new will fail without brackets on
joining the ipv6 address with :port or passing brackets to TCPSocket. It was
found that if we use Net::HTTP.start with url.hostname the incriminated code
won't be hit.

Change-Id: Ia70e05098b52121d12b035bdab59685b086523db
Closes-Bug: rhbz#1185652
This commit is contained in:
Lukas Bezdicka 2015-03-13 13:10:38 +01:00
parent 89ca576fa6
commit 2331ba06e3
1 changed files with 7 additions and 1 deletions

View File

@ -30,7 +30,13 @@ end
# A parsed URL (returned from URI.parse)
def handle_request(req, url)
begin
res = Net::HTTP.start(url.host, url.port) {|http|
# There is issue with ipv6 where address has to be in brackets, this causes the
# underlying ruby TCPSocket to fail. Net::HTTP.new will fail without brackets on
# joining the ipv6 address with :port or passing brackets to TCPSocket. It was
# found that if we use Net::HTTP.start with url.hostname the incriminated code
# won't be hit.
use_ssl = url.scheme == "https" ? true : false
res = Net::HTTP.start(url.hostname, url.port, {:use_ssl => use_ssl}) {|http|
http.request(req)
}