1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) r49104,r49105: [Backport #10692]

* test/net/http/test_http.rb (_test_send_request__HEAD): Added
	  failing test for send_request with HEAD method.

	* lib/net/http.rb (Net::HTTP#send_request): there is no response body
	  with HEAD request. Patch by @rodrigosaito [fix GH-520]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2015-02-28 16:03:10 +00:00
parent 089dbf1edd
commit 4ad3a5c32c
4 changed files with 24 additions and 2 deletions

View file

@ -1,3 +1,13 @@
Sun Mar 1 01:01:21 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* lib/net/http.rb (Net::HTTP#send_request): there is no response body
with HEAD request. Patch by @rodrigosaito [fix GH-520]
Sun Mar 1 01:01:21 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* test/net/http/test_http.rb (_test_send_request__HEAD): Added
failing test for send_request with HEAD method.
Sun Mar 1 00:58:30 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com> Sun Mar 1 00:58:30 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* ext/zlib/zlib.c: fix document of method signatures. * ext/zlib/zlib.c: fix document of method signatures.

View file

@ -1350,7 +1350,8 @@ module Net #:nodoc:
# puts response.body # puts response.body
# #
def send_request(name, path, data = nil, header = nil) def send_request(name, path, data = nil, header = nil)
r = HTTPGenericRequest.new(name,(data ? true : false),true,path,header) has_response_body = name != 'HEAD'
r = HTTPGenericRequest.new(name,(data ? true : false),has_response_body,path,header)
request r, data request r, data
end end

View file

@ -574,6 +574,7 @@ module TestNetHTTP_version_1_2_methods
def test_send_request def test_send_request
start {|http| start {|http|
_test_send_request__GET http _test_send_request__GET http
_test_send_request__HEAD http
_test_send_request__POST http _test_send_request__POST http
} }
end end
@ -588,6 +589,16 @@ module TestNetHTTP_version_1_2_methods
assert_equal $test_net_http_data, res.body assert_equal $test_net_http_data, res.body
end end
def _test_send_request__HEAD(http)
res = http.send_request('HEAD', '/')
assert_kind_of Net::HTTPResponse, res
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_nil res.body
end
def _test_send_request__POST(http) def _test_send_request__POST(http)
data = 'aaabbb cc ddddddddddd lkjoiu4j3qlkuoa' data = 'aaabbb cc ddddddddddd lkjoiu4j3qlkuoa'
res = http.send_request('POST', '/', data, 'content-type' => 'application/x-www-form-urlencoded') res = http.send_request('POST', '/', data, 'content-type' => 'application/x-www-form-urlencoded')

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.5" #define RUBY_VERSION "2.1.5"
#define RUBY_RELEASE_DATE "2015-03-01" #define RUBY_RELEASE_DATE "2015-03-01"
#define RUBY_PATCHLEVEL 301 #define RUBY_PATCHLEVEL 302
#define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 3 #define RUBY_RELEASE_MONTH 3