summaryrefslogtreecommitdiff
path: root/test/webrick/test_cgi.rb
diff options
context:
space:
mode:
author(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-01-18 06:03:43 +0000
committer(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-01-18 06:03:43 +0000
commit9f1945ac53f53bfbf4813f3ddda33cfb40e780c8 (patch)
tree1646b302a247a953a853b527e5c7b7489769ac46 /test/webrick/test_cgi.rb
parentee61635f5a765ca5e5493a63bc838fa566539a57 (diff)
This commit was manufactured by cvs2svn to create branch 'ruby_1_8'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/webrick/test_cgi.rb')
-rw-r--r--test/webrick/test_cgi.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/webrick/test_cgi.rb b/test/webrick/test_cgi.rb
new file mode 100644
index 0000000000..60d5da6a72
--- /dev/null
+++ b/test/webrick/test_cgi.rb
@@ -0,0 +1,46 @@
+require "webrick"
+require File.join(File.dirname(__FILE__), "utils.rb")
+require "test/unit"
+begin
+ loadpath = $:.dup
+ $:.replace($: | [File.expand_path("../ruby", File.dirname(__FILE__))])
+ require 'envutil'
+ensure
+ $:.replace(loadpath)
+end
+
+class TestWEBrickCGI < Test::Unit::TestCase
+ def test_cgi
+ accepted = started = stopped = 0
+ requested0 = requested1 = 0
+ config = {
+ :CGIInterpreter => EnvUtil.rubybin,
+ :DocumentRoot => File.dirname(__FILE__),
+ }
+ TestWEBrick.start_httpserver(config){|server, addr, port|
+ http = Net::HTTP.new(addr, port)
+ req = Net::HTTP::Get.new("/webrick.cgi")
+ http.request(req){|res| assert_equal("/webrick.cgi", res.body)}
+ req = Net::HTTP::Get.new("/webrick.cgi/path/info")
+ http.request(req){|res| assert_equal("/path/info", res.body)}
+ req = Net::HTTP::Get.new("/webrick.cgi/%3F%3F%3F?foo=bar")
+ http.request(req){|res| assert_equal("/???", res.body)}
+ req = Net::HTTP::Get.new("/webrick.cgi/%A4%DB%A4%B2/%A4%DB%A4%B2")
+ http.request(req){|res|
+ assert_equal("/\xA4\xDB\xA4\xB2/\xA4\xDB\xA4\xB2", res.body)}
+ req = Net::HTTP::Get.new("/webrick.cgi?a=1;a=2;b=x")
+ http.request(req){|res| assert_equal("a=1, a=2, b=x", res.body)}
+ req = Net::HTTP::Get.new("/webrick.cgi?a=1&a=2&b=x")
+ http.request(req){|res| assert_equal("a=1, a=2, b=x", res.body)}
+
+ req = Net::HTTP::Post.new("/webrick.cgi?a=x;a=y;b=1")
+ req["Content-Type"] = "application/x-www-form-urlencoded"
+ http.request(req, "a=1;a=2;b=x"){|res|
+ assert_equal("a=1, a=2, b=x", res.body)}
+ req = Net::HTTP::Post.new("/webrick.cgi?a=x&a=y&b=1")
+ req["Content-Type"] = "application/x-www-form-urlencoded"
+ http.request(req, "a=1&a=2&b=x"){|res|
+ assert_equal("a=1, a=2, b=x", res.body)}
+ }
+ end
+end