summaryrefslogtreecommitdiff
path: root/test/webrick/webrick.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'test/webrick/webrick.cgi')
-rw-r--r--test/webrick/webrick.cgi26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/webrick/webrick.cgi b/test/webrick/webrick.cgi
new file mode 100644
index 0000000000..97e1377454
--- /dev/null
+++ b/test/webrick/webrick.cgi
@@ -0,0 +1,26 @@
+#!ruby -d
+require "webrick/cgi"
+
+class TestApp < WEBrick::CGI
+ def do_GET(req, res)
+ res["content-type"] = "text/plain"
+ if p = req.path_info
+ res.body = p
+ elsif (q = req.query).size > 0
+ res.body = q.keys.sort.collect{|key|
+ q[key].list.sort.collect{|v|
+ "#{key}=#{v}"
+ }.join(", ")
+ }.join(", ")
+ else
+ res.body = req.script_name
+ end
+ end
+
+ def do_POST(req, res)
+ do_GET(req, res)
+ end
+end
+
+cgi = TestApp.new
+cgi.start