Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes REQUEST_PATH for WEBrick

  • Loading branch information...
commit 6ea66ef21a9d5d3b457fe4b0ed5e448ee1b2c1ba 1 parent 582a78b
Andrew Stevens authored josh committed
Showing with 6 additions and 5 deletions.
  1. +1 −1  lib/rack/handler/webrick.rb
  2. +5 −4 test/spec_webrick.rb
View
2  lib/rack/handler/webrick.rb
@@ -43,11 +43,11 @@ def service(req, res)
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
View
9 test/spec_webrick.rb
@@ -43,7 +43,7 @@
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 @@
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 @@
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"
Please sign in to comment.
Something went wrong with that request. Please try again.