summaryrefslogtreecommitdiffstats
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
commit38988f9382969ce92dda068b27d7456e22af699e (patch)
tree2edb32aa0e4707af11c9a3215f08de4fd83f6a6e /test/net/http
parent4f077a4d8b8a40b14e14d397fbb1ebd68f74c6eb (diff)
downloadruby-38988f9382969ce92dda068b27d7456e22af699e.tar.gz
ruby-38988f9382969ce92dda068b27d7456e22af699e.tar.xz
ruby-38988f9382969ce92dda068b27d7456e22af699e.zip
* 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: http://svn.ruby-lang.org/repos/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 1a8751e28..3d5fa141e 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