summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 14:39:06 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 14:39:06 +0000
commit88243c5303ec5db2a58e355dd494b63f85b85558 (patch)
tree979b1c12b8922d31efdd2133420862a089289001 /test
parent8ec6fcb2f6cd9bc453173477eb237298a5e5bab5 (diff)
* lib/net/http.rb (Net::HTTP.post): new convenience method to send a POST request.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/net/http/test_http.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb
index 9dd665c530..f2c03f2915 100644
--- a/test/net/http/test_http.rb
+++ b/test/net/http/test_http.rb
@@ -384,6 +384,22 @@ module TestNetHTTP_version_1_1_methods
end
end
+ def test_s_post
+ url = "http://#{config('host')}:#{config('port')}/"
+ res = Net::HTTP.post(
+ URI.parse(url),
+ "a=x")
+ assert_equal "application/x-www-form-urlencoded", res["Content-Type"]
+ assert_equal "a=x", res.body
+
+ res = Net::HTTP.post(
+ URI.parse(url),
+ "hello world",
+ "Content-Type" => "text/plain; charset=US-ASCII")
+ assert_equal "text/plain; charset=US-ASCII", res["Content-Type"]
+ assert_equal "hello world", res.body
+ end
+
def test_s_post_form
url = "http://#{config('host')}:#{config('port')}/"
res = Net::HTTP.post_form(