From 0d375e732d83c96451a671f7eb9522c773cd3038 Mon Sep 17 00:00:00 2001 From: knu Date: Wed, 5 Jan 2011 04:58:57 +0000 Subject: [PATCH] * lib/net/http.rb (Net::HTTP#get): A header hash given should not be modified. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/net/http.rb | 4 +++- test/net/http/test_http.rb | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 418012c931..fbbe4477cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jan 5 13:56:54 2011 Akinori MUSHA + + * lib/net/http.rb (Net::HTTP#get): A header hash given should not + be modified. + Wed Jan 5 13:56:03 2011 Aaron Patterson * SSL_shutdown should be called until the return value is non-zero: diff --git a/lib/net/http.rb b/lib/net/http.rb index cc0a0b20dc..fac9a0beb1 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -987,7 +987,9 @@ module Net #:nodoc: res = nil if HAVE_ZLIB unless initheader.keys.any?{|k| k.downcase == "accept-encoding"} - initheader["accept-encoding"] = "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" + initheader = initheader.merge({ + "accept-encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" + }) @compression = true end end diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 5e5cdab9ff..9833a8e9e5 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -42,6 +42,10 @@ module TestNetHTTP_version_1_1_methods assert_equal $test_net_http_data_type, res['Content-Type'] assert_equal $test_net_http_data.size, res.body.size assert_equal $test_net_http_data, res.body + + assert_nothing_raised { + res, body = http.get('/', { 'User-Agent' => 'test' }.freeze) + } end def _test_get__iter(http)