ruby-changes:18128
From: naruse <ko1@a...>
Date: Fri, 10 Dec 2010 10:08:54 +0900 (JST)
Subject: [ruby-changes:18128] Ruby:r30154 (trunk): * lib/net/http.rb: remove version 1.1 features.
naruse 2010-12-10 10:08:45 +0900 (Fri, 10 Dec 2010) New Revision: 30154 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30154 Log: * lib/net/http.rb: remove version 1.1 features. Modified files: trunk/ChangeLog trunk/lib/net/http.rb trunk/test/net/http/test_http.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 30153) +++ ChangeLog (revision 30154) @@ -1,3 +1,7 @@ +Fri Dec 10 10:07:59 2010 NARUSE, Yui <naruse@r...> + + * lib/net/http.rb: remove version 1.1 features. + Fri Dec 10 02:18:02 2010 Aaron Patterson <aaron@t...> * ext/openssl/ossl_x509store.c (ossl_x509stctx_cleanup): removing C Index: lib/net/http.rb =================================================================== --- lib/net/http.rb (revision 30153) +++ lib/net/http.rb (revision 30154) @@ -358,29 +358,11 @@ # There is also the Net::HTTPBadResponse exception which is raised when # there is a protocol error. # - # == Switching Net::HTTP versions - # - # You can use net/http.rb 1.1 features (bundled with Ruby 1.6) by calling - # HTTP.version_1_1. Calling Net::HTTP.version_1_2 allows you to use 1.2 - # features again. Do not confuse this with HTTP protocol features. - # - # # example - # Net::HTTP.start {|http1| ...(http1 has 1.2 features)... } - # - # Net::HTTP.version_1_1 - # Net::HTTP.start {|http2| ...(http2 has 1.1 features)... } - # - # Net::HTTP.version_1_2 - # Net::HTTP.start {|http3| ...(http3 has 1.2 features)... } - # - # Switching versions is NOT thread-safe. - # class HTTP < Protocol # :stopdoc: Revision = %q$Revision$.split[1] HTTPVersion = '1.1' - @newimpl = true begin require 'zlib' require 'stringio' #for our purposes (unpacking gzip) lump these together @@ -393,25 +375,18 @@ # Turns on net/http 1.2 (ruby 1.8) features. # Defaults to ON in ruby 1.8 or later. def HTTP.version_1_2 - @newimpl = true + true end - # Turns on net/http 1.1 (ruby 1.6) features. - # Defaults to OFF in ruby 1.8. - def HTTP.version_1_1 - @newimpl = false - end - # Returns true if net/http is in version 1.2 mode. # Defaults to true. def HTTP.version_1_2? - @newimpl + true end - # Returns true if net/http is in version 1.1 compatible mode. - # Defaults to true. + # :nodoc: def HTTP.version_1_1? - not @newimpl + false end class << HTTP @@ -588,11 +563,7 @@ # The +address+ should be a DNS hostname or IP address. # If +p_addr+ is given, creates a Net::HTTP object with proxy support. def HTTP.new(address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil) - h = Proxy(p_addr, p_port, p_user, p_pass).newobj(address, port) - h.instance_eval { - @newimpl = ::Net::HTTP.version_1_2? - } - h + Proxy(p_addr, p_port, p_user, p_pass).newobj(address, port) end # Creates a new Net::HTTP object for the specified server address, @@ -988,10 +959,7 @@ # the header as well to prevent confusion. Otherwise # it leaves the body as it found it. # - # In version 1.1 (ruby 1.6), this method returns a pair of objects, - # a Net::HTTPResponse object and the entity body string. - # In version 1.2 (ruby 1.8), this method returns a Net::HTTPResponse - # object. + # This method returns a Net::HTTPResponse object. # # If called with a block, yields each fragment of the # entity body in turn as a string as it is read from @@ -1001,16 +969,8 @@ # +dest+ argument is obsolete. # It still works but you must not use it. # - # In version 1.1, this method might raise an exception for - # 3xx (redirect). In this case you can get a HTTPResponse object - # from "anException.response". + # This method never raises an exception. # - # In version 1.2, this method never raises an exception. - # - # # version 1.1 (bundled with Ruby 1.6) - # response, body = http.get('/index.html') - # - # # version 1.2 (bundled with Ruby 1.8 or later) # response = http.get('/index.html') # # # using block @@ -1049,11 +1009,6 @@ end res = r } - unless @newimpl - res.value - return res, res.body - end - res end @@ -1062,12 +1017,8 @@ # # This method returns a Net::HTTPResponse object. # - # In version 1.1, this method might raise an exception for - # 3xx (redirect). On the case you can get a HTTPResponse object - # as "anException.response". + # This method never raises an exception. # - # In version 1.2, this method never raises an exception. - # # response = nil # Net::HTTP.start('some.www.server', 80) {|http| # response = http.head('/index.html') @@ -1075,17 +1026,13 @@ # p response['content-type'] # def head(path, initheader = nil) - res = request(Head.new(path, initheader)) - res.value unless @newimpl - res + request(Head.new(path, initheader)) end # Posts +data+ (must be a String) to +path+. +header+ must be a Hash # like { 'Accept' => '*/*', ... }. # - # In version 1.1 (ruby 1.6), this method returns a pair of objects, a - # Net::HTTPResponse object and an entity body string. - # In version 1.2 (ruby 1.8), this method returns a Net::HTTPResponse object. + # This method returns a Net::HTTPResponse object. # # If called with a block, yields each fragment of the # entity body in turn as a string as it is read from @@ -1095,15 +1042,8 @@ # +dest+ argument is obsolete. # It still works but you must not use it. # - # In version 1.1, this method might raise an exception for - # 3xx (redirect). In this case you can get an HTTPResponse object - # by "anException.response". - # In version 1.2, this method never raises exception. + # This method never raises exception. # - # # version 1.1 - # response, body = http.post('/cgi-bin/search.rb', 'query=foo') - # - # # version 1.2 # response = http.post('/cgi-bin/search.rb', 'query=foo') # # # using block @@ -1128,9 +1068,7 @@ end def put(path, data, initheader = nil) #:nodoc: - res = request(Put.new(path, initheader), data) - res.value unless @newimpl - res + request(Put.new(path, initheader), data) end # Sends a PROPPATCH request to the +path+ and gets a response, @@ -1335,10 +1273,6 @@ r.read_body dest, &block res = r } - unless @newimpl - res.value - return res, res.body - end res end @@ -2493,21 +2427,7 @@ "#<#{self.class} #{@code} #{@message} readbody=#{@read}>" end - # For backward compatibility. - # To allow Net::HTTP 1.1 style assignment - # e.g. - # response, body = Net::HTTP.get(....) # - def to_ary - warn "net/http.rb: warning: Net::HTTP v1.1 style assignment found at #{caller(1)[0]}; use `response = http.get(...)' instead." if $VERBOSE - res = self.dup - class << res - undef to_ary - end - [res, res.body] - end - - # # response <-> exception relationship # Index: test/net/http/test_http.rb =================================================================== --- test/net/http/test_http.rb (revision 30153) +++ test/net/http/test_http.rb (revision 30154) @@ -32,27 +32,23 @@ end def _test_get__get(http) - res, body = http.get('/') + res = http.get('/') assert_kind_of Net::HTTPResponse, res assert_kind_of String, res.body - assert_kind_of String, body unless self.is_a?(TestNetHTTP_v1_2_chunked) assert_not_nil res['content-length'] assert_equal $test_net_http_data.size, res['content-length'].to_i end assert_equal $test_net_http_data_type, res['Content-Type'] - assert_equal $test_net_http_data.size, body.size - assert_equal $test_net_http_data, body assert_equal $test_net_http_data.size, res.body.size assert_equal $test_net_http_data, res.body end def _test_get__iter(http) buf = '' - res, body = http.get('/') {|s| buf << s } + res = http.get('/') {|s| buf << s } assert_kind_of Net::HTTPResponse, res # assert_kind_of String, res.body - # assert_kind_of String, body unless self.is_a?(TestNetHTTP_v1_2_chunked) assert_not_nil res['content-length'] assert_equal $test_net_http_data.size, res['content-length'].to_i @@ -66,10 +62,9 @@ def _test_get__chunked(http) buf = '' - res, body = http.get('/') {|s| buf << s } + res = http.get('/') {|s| buf << s } assert_kind_of Net::HTTPResponse, res # assert_kind_of String, res.body - # assert_kind_of String, body unless self.is_a?(TestNetHTTP_v1_2_chunked) assert_not_nil res['content-length'] assert_equal $test_net_http_data.size, res['content-length'].to_i @@ -93,9 +88,8 @@ end def test_get__implicit_start - res, body = new().get('/') + res = new().get('/') assert_kind_of Net::HTTPResponse, res - assert_kind_of String, body assert_kind_of String, res.body unless self.is_a?(TestNetHTTP_v1_2_chunked) assert_not_nil res['content-length'] @@ -134,11 +128,9 @@ uheader = {} uheader['Accept'] = 'application/octet-stream' data = 'post data' - res, body = http.post('/', data) + res = http.post('/', data) assert_kind_of Net::HTTPResponse, res - assert_kind_of String, body assert_kind_of String, res.body - assert_equal data, body assert_equal data, res.body assert_equal data, res.entity end @@ -179,11 +171,9 @@ uheader = {} uheader['Accept'] = 'application/octet-stream' data = 'patch data' - res, body = http.patch('/', data) + res = http.patch('/', data) assert_kind_of Net::HTTPResponse, res - assert_kind_of String, body assert_kind_of String, res.body - assert_equal data, body assert_equal data, res.body assert_equal data, res.entity end @@ -305,23 +295,6 @@ end end -class TestNetHTTP_version_1_1 < Test::Unit::TestCase - CONFIG = { - 'host' => '127.0.0.1', - 'port' => 10081, - 'proxy_host' => nil, - 'proxy_port' => nil, - } - - include TestNetHTTPUtils - include TestNetHTTP_version_1_1_methods - - def new - Net::HTTP.version_1_1 - super - end -end - class TestNetHTTP_v1_2 < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', @@ -371,23 +344,3 @@ } end end - -=begin -class TestNetHTTP_proxy < Test::Unit::TestCase - CONFIG = { - 'host' => '127.0.0.1', - 'port' => 10081, - 'proxy_host' => '127.0.0.1', - 'proxy_port' => 10082, - } - - include TestNetHTTPUtils - include TestNetHTTP_version_1_1_methods - include TestNetHTTP_version_1_2_methods - - def new - Net::HTTP.version_1_2 - super - end -end -=end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/