Skip to content

Commit 4ad3a5c

Browse files
committed
merge revision(s) r49104,r49105: [Backport ruby#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 rubyGH-520] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 089dbf1 commit 4ad3a5c

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Sun Mar 1 01:01:21 2015 SHIBATA Hiroshi <[email protected]>
2+
3+
* lib/net/http.rb (Net::HTTP#send_request): there is no response body
4+
with HEAD request. Patch by @rodrigosaito [fix GH-520]
5+
6+
Sun Mar 1 01:01:21 2015 SHIBATA Hiroshi <[email protected]>
7+
8+
* test/net/http/test_http.rb (_test_send_request__HEAD): Added
9+
failing test for send_request with HEAD method.
10+
111
Sun Mar 1 00:58:30 2015 SHIBATA Hiroshi <[email protected]>
212

313
* ext/zlib/zlib.c: fix document of method signatures.

lib/net/http.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,8 @@ def request_put(path, data, initheader = nil, &block) #:nodoc:
13501350
# puts response.body
13511351
#
13521352
def send_request(name, path, data = nil, header = nil)
1353-
r = HTTPGenericRequest.new(name,(data ? true : false),true,path,header)
1353+
has_response_body = name != 'HEAD'
1354+
r = HTTPGenericRequest.new(name,(data ? true : false),has_response_body,path,header)
13541355
request r, data
13551356
end
13561357

test/net/http/test_http.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ def _test_request__uri_host(http)
574574
def test_send_request
575575
start {|http|
576576
_test_send_request__GET http
577+
_test_send_request__HEAD http
577578
_test_send_request__POST http
578579
}
579580
end
@@ -588,6 +589,16 @@ def _test_send_request__GET(http)
588589
assert_equal $test_net_http_data, res.body
589590
end
590591

592+
def _test_send_request__HEAD(http)
593+
res = http.send_request('HEAD', '/')
594+
assert_kind_of Net::HTTPResponse, res
595+
unless self.is_a?(TestNetHTTP_v1_2_chunked)
596+
assert_not_nil res['content-length']
597+
assert_equal $test_net_http_data.size, res['content-length'].to_i
598+
end
599+
assert_nil res.body
600+
end
601+
591602
def _test_send_request__POST(http)
592603
data = 'aaabbb cc ddddddddddd lkjoiu4j3qlkuoa'
593604
res = http.send_request('POST', '/', data, 'content-type' => 'application/x-www-form-urlencoded')

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.5"
22
#define RUBY_RELEASE_DATE "2015-03-01"
3-
#define RUBY_PATCHLEVEL 301
3+
#define RUBY_PATCHLEVEL 302
44

55
#define RUBY_RELEASE_YEAR 2015
66
#define RUBY_RELEASE_MONTH 3

0 commit comments

Comments
 (0)