ruby-changes:26528
From: naruse <ko1@a...>
Date: Mon, 24 Dec 2012 05:01:16 +0900 (JST)
Subject: [ruby-changes:26528] naruse:r38578 (trunk): * lib/net/http/generic_request.rb (Net::HTTPGenericRequest):
naruse 2012-12-24 04:58:44 +0900 (Mon, 24 Dec 2012) New Revision: 38578 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38578 Log: * lib/net/http/generic_request.rb (Net::HTTPGenericRequest): set content-length to zero on empty post requests by Gregory Ostermayr <gregory.ostermayr@g...> https://github.com/ruby/ruby/pull/201 fix GH-201 Modified files: trunk/ChangeLog trunk/lib/net/http/generic_request.rb trunk/test/net/http/test_http.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 38577) +++ ChangeLog (revision 38578) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Dec 24 04:56:48 2012 NARUSE, Yui <naruse@r...> + + * lib/net/http/generic_request.rb (Net::HTTPGenericRequest): + set content-length to zero on empty post requests + by Gregory Ostermayr <gregory.ostermayr@g...> + https://github.com/ruby/ruby/pull/201 fix GH-201 + Sun Dec 23 19:09:16 2012 Koichi Sasada <ko1@a...> * thread.c: rename methods: Index: lib/net/http/generic_request.rb =================================================================== --- lib/net/http/generic_request.rb (revision 38577) +++ lib/net/http/generic_request.rb (revision 38578) @@ -89,6 +89,9 @@ class Net::HTTPGenericRequest https://github.com/ruby/ruby/blob/trunk/lib/net/http/generic_request.rb#L89 def set_body_internal(str) #:nodoc: internal use only raise ArgumentError, "both of body argument and HTTPRequest#body set" if str and (@body or @body_stream) self.body = str if str + if @body.nil? && @body_stream.nil? && @body_data.nil? && request_body_permitted? + self.body = '' + end end # Index: test/net/http/test_http.rb =================================================================== --- test/net/http/test_http.rb (revision 38577) +++ test/net/http/test_http.rb (revision 38578) @@ -310,6 +310,7 @@ module TestNetHTTP_version_1_1_methods https://github.com/ruby/ruby/blob/trunk/test/net/http/test_http.rb#L310 start {|http| _test_post__base http _test_post__file http + _test_post__no_data http } end @@ -332,6 +333,14 @@ module TestNetHTTP_version_1_1_methods https://github.com/ruby/ruby/blob/trunk/test/net/http/test_http.rb#L333 assert_equal data, f.string end + def _test_post__no_data(http) + unless self.is_a?(TestNetHTTP_v1_2_chunked) + data = nil + res = http.post('/', data) + assert_not_equal '411', res.code + end + end + def test_s_post_form url = "http://#{config('host')}:#{config('port')}/" res = Net::HTTP.post_form( -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/