summaryrefslogtreecommitdiff
path: root/test/net/http
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-04-20 13:55:26 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-04-20 13:55:26 +0000
commit9d0758b3b0f85a0a3ca26e1e83b4a6f04c460873 (patch)
tree2edb32aa0e4707af11c9a3215f08de4fd83f6a6e /test/net/http
parent75cff6289c53155bfa73e7cc98bad0b12fab317f (diff)
* lib/net/http.rb: new method Net::HTTP.post_form.
* lib/net/http.rb: new method Net::HTTPHeader#set_form_data and its alias #form_data=. * lib/net/http.rb: Net::HTTPHeader#add_header -> add_field (adjustted to Ruby 1.8). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/http')
-rw-r--r--test/net/http/test_httpheader.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/net/http/test_httpheader.rb b/test/net/http/test_httpheader.rb
index 1a8751e28c..3d5fa141ef 100644
--- a/test/net/http/test_httpheader.rb
+++ b/test/net/http/test_httpheader.rb
@@ -7,7 +7,9 @@ class HTTPHeaderTest < Test::Unit::TestCase
include Net::HTTPHeader
def initialize
@header = {}
+ @body = nil
end
+ attr_accessor :body
end
def setup
@@ -203,6 +205,26 @@ class HTTPHeaderTest < Test::Unit::TestCase
def test_set_content_type
end
+ def test_form_data=
+ @c.form_data = {"cmd"=>"search", "q"=>"ruby", "max"=>"50"}
+ assert_equal 'application/x-www-form-urlencoded', @c.content_type
+ assert_equal %w( cmd=search max=50 q=ruby ), @c.body.split('&').sort
+ end
+
+ def test_set_form_data
+ @c.set_form_data "cmd"=>"search", "q"=>"ruby", "max"=>"50"
+ assert_equal 'application/x-www-form-urlencoded', @c.content_type
+ assert_equal %w( cmd=search max=50 q=ruby ), @c.body.split('&').sort
+
+ @c.set_form_data "cmd"=>"search", "q"=>"ruby", "max"=>50
+ assert_equal 'application/x-www-form-urlencoded', @c.content_type
+ assert_equal %w( cmd=search max=50 q=ruby ), @c.body.split('&').sort
+
+ @c.set_form_data({"cmd"=>"search", "q"=>"ruby", "max"=>"50"}, ';')
+ assert_equal 'application/x-www-form-urlencoded', @c.content_type
+ assert_equal %w( cmd=search max=50 q=ruby ), @c.body.split(';').sort
+ end
+
def test_basic_auth
end