diff options
author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-21 17:44:44 +0000 |
---|---|---|
committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-21 17:44:44 +0000 |
commit | 800c313bde129b5e54d41abd478e1be6dab63016 (patch) | |
tree | abaf528c804a97592ef88c12bbfe8bb3860c8e26 | |
parent | 7d112260586c99168bc51df274784bcc01db6692 (diff) | |
download | ruby-800c313bde129b5e54d41abd478e1be6dab63016.tar.gz |
* lib/net/http.rb (Net::HTTP.post_form): Do not ignore query part of
the given URI to post. See #655.
* test/net/http/test_http.rb, test/net/http/utils.rb: Test it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | lib/net/http.rb | 2 | ||||
-rw-r--r-- | test/net/http/test_http.rb | 14 | ||||
-rw-r--r-- | test/net/http/utils.rb | 1 |
4 files changed, 20 insertions, 4 deletions
@@ -1,3 +1,10 @@ +Wed Jun 22 02:39:54 2011 Hiroshi Nakamura <nahi@ruby-lang.org> + + * lib/net/http.rb (Net::HTTP.post_form): Do not ignore query part of + the given URI to post. See #655. + + * test/net/http/test_http.rb, test/net/http/utils.rb: Test it. + Wed Jun 22 01:28:13 2011 Hiroshi Nakamura <nahi@ruby-lang.org> * test/openssl/test_x509store.rb (test_set_errors): Redhat is diff --git a/lib/net/http.rb b/lib/net/http.rb index 045967caa3..f89858836f 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -475,7 +475,7 @@ module Net #:nodoc: # { "q" => "ruby", "max" => "50" } # def HTTP.post_form(url, params) - req = Post.new(url.path) + req = Post.new(url.request_uri) req.form_data = params req.basic_auth url.user, url.password if url.user new(url.hostname, url.port).start {|http| diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 9a7a149702..660c0ffa7c 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -147,22 +147,30 @@ module TestNetHTTP_version_1_1_methods end def test_s_post_form + url = "http://#{config('host')}:#{config('port')}/" res = Net::HTTP.post_form( - URI.parse("http://#{config('host')}:#{config('port')}/"), + URI.parse(url), "a" => "x") assert_equal ["a=x"], res.body.split(/[;&]/).sort res = Net::HTTP.post_form( - URI.parse("http://#{config('host')}:#{config('port')}/"), + URI.parse(url), "a" => "x", "b" => "y") assert_equal ["a=x", "b=y"], res.body.split(/[;&]/).sort res = Net::HTTP.post_form( - URI.parse("http://#{config('host')}:#{config('port')}/"), + URI.parse(url), "a" => ["x1", "x2"], "b" => "y") + assert_equal url, res['X-request-uri'] assert_equal ["a=x1", "a=x2", "b=y"], res.body.split(/[;&]/).sort + + res = Net::HTTP.post_form( + URI.parse(url + '?a=x'), + "b" => "y") + assert_equal url + '?a=x', res['X-request-uri'] + assert_equal ["b=y"], res.body.split(/[;&]/).sort end def test_patch diff --git a/test/net/http/utils.rb b/test/net/http/utils.rb index 227c39fc9b..50f616f29f 100644 --- a/test/net/http/utils.rb +++ b/test/net/http/utils.rb @@ -91,6 +91,7 @@ module TestNetHTTPUtils # echo server def do_POST(req, res) res['Content-Type'] = req['Content-Type'] + res['X-request-uri'] = req.request_uri.to_s res.body = req.body res.chunked = @chunked end |