[前][次][番号順一覧][スレッド一覧]

ruby-changes:34995

From: naruse <ko1@a...>
Date: Wed, 6 Aug 2014 04:10:35 +0900 (JST)
Subject: [ruby-changes:34995] naruse:r47077 (trunk): * lib/net/http/generic_request.rb (Net::HTTP::GenericRequest#exec):

naruse	2014-08-06 04:10:23 +0900 (Wed, 06 Aug 2014)

  New Revision: 47077

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47077

  Log:
    * 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]

  Modified files:
    trunk/ChangeLog
    trunk/lib/net/http/generic_request.rb
    trunk/test/net/http/test_http.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47076)
+++ ChangeLog	(revision 47077)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Aug  6 03:18:04 2014  NARUSE, Yui  <naruse@r...>
+
+	* 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@r...>
 
 	* lib/net/http/generic_request.rb
Index: lib/net/http/generic_request.rb
===================================================================
--- lib/net/http/generic_request.rb	(revision 47076)
+++ lib/net/http/generic_request.rb	(revision 47077)
@@ -116,15 +116,6 @@ class Net::HTTPGenericRequest https://github.com/ruby/ruby/blob/trunk/lib/net/http/generic_request.rb#L116
   #
 
   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 https://github.com/ruby/ruby/blob/trunk/lib/net/http/generic_request.rb#L139
       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
Index: test/net/http/test_http.rb
===================================================================
--- test/net/http/test_http.rb	(revision 47076)
+++ test/net/http/test_http.rb	(revision 47077)
@@ -563,10 +563,10 @@ module TestNetHTTP_version_1_2_methods https://github.com/ruby/ruby/blob/trunk/test/net/http/test_http.rb#L563
   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)
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]