diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | lib/net/http/generic_request.rb | 13 | ||||
-rw-r--r-- | test/net/http/test_http.rb | 4 |
3 files changed, 15 insertions, 13 deletions
@@ -1,3 +1,14 @@ +Wed Aug 6 03:18:04 2014 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/net/http/generic_request.rb (Net::HTTP::GenericRequest#exec): + handle req['host'] in update_uri. + + * lib/net/http/generic_request.rb + (Net::HTTP::GenericRequest#update_uri): + use req['host'] if it is explicitly set. Even if URI is given, + it is already used for the initial value of req['host']. + Therefore overwritten value should be respected. [Bug #10054] + Wed Aug 6 03:17:34 2014 NARUSE, Yui <naruse@ruby-lang.org> * lib/net/http/generic_request.rb diff --git a/lib/net/http/generic_request.rb b/lib/net/http/generic_request.rb index f410d5838e..00ff434ccf 100644 --- a/lib/net/http/generic_request.rb +++ b/lib/net/http/generic_request.rb @@ -116,15 +116,6 @@ class Net::HTTPGenericRequest # def exec(sock, ver, path) #:nodoc: internal use only - if @uri - if @uri.port == @uri.default_port - # [Bug #7650] Amazon ECS API and GFE/1.3 disallow extra default port number - self['host'] = @uri.host - else - self['host'] = "#{@uri.host}:#{@uri.port}" - end - end - if @body send_request_with_body sock, ver, path, @body elsif @body_stream @@ -148,9 +139,9 @@ class Net::HTTPGenericRequest klass = URI::HTTP end - if host = @uri.host - elsif host = self['host'] + if host = self['host'] host.sub!(/:.*/s, ''.freeze) + elsif host = @uri.host else host = addr end diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 9def957b48..704456f3a3 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -563,10 +563,10 @@ module TestNetHTTP_version_1_2_methods end def _test_request__uri_host(http) - uri = URI 'http://example/' + uri = URI 'http://other.example/' req = Net::HTTP::Get.new(uri) - req['host'] = 'other.example' + req['host'] = 'example' res = http.request(req) |