summary refs log tree commit
diff options
context:
space:
mode:
authorAndrew Stevens <astevens@tstmedia.com>2010-11-18 20:15:02 +0800
committerJoshua Peek <josh@joshpeek.com>2010-12-10 04:12:43 +0800
commit6ea66ef21a9d5d3b457fe4b0ed5e448ee1b2c1ba (patch)
tree7d502e84da87a7bfb73e7fa5bb7265ddaef465c0
parent582a78beb987109c0246ad12d3ecbcddd0e00085 (diff)
downloadrack-6ea66ef21a9d5d3b457fe4b0ed5e448ee1b2c1ba.tar.gz
Fixes REQUEST_PATH for WEBrick
-rw-r--r--lib/rack/handler/webrick.rb2
-rw-r--r--test/spec_webrick.rb9
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/rack/handler/webrick.rb b/lib/rack/handler/webrick.rb
index 342e4434..0a020e4d 100644
--- a/lib/rack/handler/webrick.rb
+++ b/lib/rack/handler/webrick.rb
@@ -43,11 +43,11 @@ module Rack
 
         env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
         env["QUERY_STRING"] ||= ""
-        env["REQUEST_PATH"] ||= "/"
         unless env["PATH_INFO"] == ""
           path, n = req.request_uri.path, env["SCRIPT_NAME"].length
           env["PATH_INFO"] = path[n, path.length-n]
         end
+        env["REQUEST_PATH"] ||= [env["SCRIPT_NAME"], env["PATH_INFO"]].join
 
         status, headers, body = @app.call(env)
         begin
diff --git a/test/spec_webrick.rb b/test/spec_webrick.rb
index 13cfa07c..e3af2337 100644
--- a/test/spec_webrick.rb
+++ b/test/spec_webrick.rb
@@ -43,7 +43,7 @@ describe Rack::Handler::WEBrick do
     GET("/test")
     response["REQUEST_METHOD"].should.equal "GET"
     response["SCRIPT_NAME"].should.equal "/test"
-    response["REQUEST_PATH"].should.equal "/"
+    response["REQUEST_PATH"].should.equal "/test"
     response["PATH_INFO"].should.be.equal ""
     response["QUERY_STRING"].should.equal ""
     response["test.postdata"].should.equal ""
@@ -51,14 +51,14 @@ describe Rack::Handler::WEBrick do
     GET("/test/foo?quux=1")
     response["REQUEST_METHOD"].should.equal "GET"
     response["SCRIPT_NAME"].should.equal "/test"
-    response["REQUEST_PATH"].should.equal "/"
+    response["REQUEST_PATH"].should.equal "/test/foo"
     response["PATH_INFO"].should.equal "/foo"
     response["QUERY_STRING"].should.equal "quux=1"
 
     GET("/test/foo%25encoding?quux=1")
     response["REQUEST_METHOD"].should.equal "GET"
     response["SCRIPT_NAME"].should.equal "/test"
-    response["REQUEST_PATH"].should.equal "/"
+    response["REQUEST_PATH"].should.equal "/test/foo%25encoding"
     response["PATH_INFO"].should.equal "/foo%25encoding"
     response["QUERY_STRING"].should.equal "quux=1"
   end
@@ -68,7 +68,8 @@ describe Rack::Handler::WEBrick do
     status.should.equal 200
     response["REQUEST_METHOD"].should.equal "POST"
     response["SCRIPT_NAME"].should.equal "/test"
-    response["REQUEST_PATH"].should.equal "/"
+    response["REQUEST_PATH"].should.equal "/test"
+    response["PATH_INFO"].should.equal ""
     response["QUERY_STRING"].should.equal ""
     response["HTTP_X_TEST_HEADER"].should.equal "42"
     response["test.postdata"].should.equal "rack-form-data=23"