summary refs log tree commit
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-12-10 21:03:32 -0600
committerJoshua Peek <josh@joshpeek.com>2009-12-10 21:03:32 -0600
commitec8e0696bcd991d6bd5ea12799af6d3edee302ef (patch)
tree55ae39f42263adf26b25006b8173d558a3bcad3a
parent324a89f2d803252e5e9013c63a4ef735863ca9af (diff)
downloadrack-ec8e0696bcd991d6bd5ea12799af6d3edee302ef.tar.gz
Don't delete PATH_INFO from env in fastcgi, mongrel, and webrick
handlers because PATH_INFO must not be nil according to SPEC
[#75 state:resolved]
-rw-r--r--lib/rack/handler/fastcgi.rb3
-rw-r--r--lib/rack/handler/mongrel.rb3
-rw-r--r--lib/rack/handler/webrick.rb4
-rw-r--r--test/spec_rack_cgi.rb4
-rw-r--r--test/spec_rack_fastcgi.rb2
-rw-r--r--test/spec_rack_mongrel.rb6
-rw-r--r--test/spec_rack_webrick.rb6
7 files changed, 12 insertions, 16 deletions
diff --git a/lib/rack/handler/fastcgi.rb b/lib/rack/handler/fastcgi.rb
index 1739d659..d8301474 100644
--- a/lib/rack/handler/fastcgi.rb
+++ b/lib/rack/handler/fastcgi.rb
@@ -33,7 +33,7 @@ module Rack
         env.delete "HTTP_CONTENT_LENGTH"
 
         env["SCRIPT_NAME"] = ""  if env["SCRIPT_NAME"] == "/"
-        
+
         rack_input = RewindableInput.new(request.in)
 
         env.update({"rack.version" => [1,0],
@@ -50,7 +50,6 @@ module Rack
         env["QUERY_STRING"] ||= ""
         env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
         env["REQUEST_PATH"] ||= "/"
-        env.delete "PATH_INFO"  if env["PATH_INFO"] == ""
         env.delete "CONTENT_TYPE"  if env["CONTENT_TYPE"] == ""
         env.delete "CONTENT_LENGTH"  if env["CONTENT_LENGTH"] == ""
 
diff --git a/lib/rack/handler/mongrel.rb b/lib/rack/handler/mongrel.rb
index cd1af2de..21f9f134 100644
--- a/lib/rack/handler/mongrel.rb
+++ b/lib/rack/handler/mongrel.rb
@@ -14,7 +14,7 @@ module Rack
           options[:throttle]       || 0,
           options[:timeout]        || 60)
         # Acts like Rack::URLMap, utilizing Mongrel's own path finding methods.
-        # Use is similar to #run, replacing the app argument with a hash of
+        # Use is similar to #run, replacing the app argument with a hash of
         # { path=>app, ... } or an instance of Rack::URLMap.
         if options[:map]
           if app.is_a? Hash
@@ -63,7 +63,6 @@ module Rack
                      "rack.url_scheme" => "http",
                    })
         env["QUERY_STRING"] ||= ""
-        env.delete "PATH_INFO"  if env["PATH_INFO"] == ""
 
         status, headers, body = @app.call(env)
 
diff --git a/lib/rack/handler/webrick.rb b/lib/rack/handler/webrick.rb
index 5b9ae740..43286113 100644
--- a/lib/rack/handler/webrick.rb
+++ b/lib/rack/handler/webrick.rb
@@ -40,9 +40,7 @@ module Rack
         env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
         env["QUERY_STRING"] ||= ""
         env["REQUEST_PATH"] ||= "/"
-        if env["PATH_INFO"] == ""
-          env.delete "PATH_INFO"
-        else
+        unless env["PATH_INFO"] == ""
           path, n = req.request_uri.path, env["SCRIPT_NAME"].length
           env["PATH_INFO"] = path[n, path.length-n]
         end
diff --git a/test/spec_rack_cgi.rb b/test/spec_rack_cgi.rb
index 818fabdf..97456320 100644
--- a/test/spec_rack_cgi.rb
+++ b/test/spec_rack_cgi.rb
@@ -3,7 +3,7 @@ require 'testrequest'
 
 context "Rack::Handler::CGI" do
   include TestRequest::Helpers
-  
+
   setup do
     @host = '0.0.0.0'
     @port = 9203
@@ -47,7 +47,7 @@ context "Rack::Handler::CGI" do
     response["REQUEST_METHOD"].should.equal "GET"
     response["SCRIPT_NAME"].should.equal "/test"
     response["REQUEST_PATH"].should.equal "/"
-    response["PATH_INFO"].should.be.nil
+    response["PATH_INFO"].should.equal ""
     response["QUERY_STRING"].should.equal ""
     response["test.postdata"].should.equal ""
 
diff --git a/test/spec_rack_fastcgi.rb b/test/spec_rack_fastcgi.rb
index 69478de5..98963c0e 100644
--- a/test/spec_rack_fastcgi.rb
+++ b/test/spec_rack_fastcgi.rb
@@ -47,7 +47,7 @@ context "Rack::Handler::FastCGI" do
     response["REQUEST_METHOD"].should.equal "GET"
     response["SCRIPT_NAME"].should.equal "/test.fcgi"
     response["REQUEST_PATH"].should.equal "/"
-    response["PATH_INFO"].should.be.nil
+    response["PATH_INFO"].should.equal ""
     response["QUERY_STRING"].should.equal ""
     response["test.postdata"].should.equal ""
 
diff --git a/test/spec_rack_mongrel.rb b/test/spec_rack_mongrel.rb
index d73e884c..6a69af75 100644
--- a/test/spec_rack_mongrel.rb
+++ b/test/spec_rack_mongrel.rb
@@ -6,14 +6,14 @@ require 'rack/urlmap'
 require 'rack/lint'
 require 'testrequest'
 require 'timeout'
-  
+
 Thread.abort_on_exception = true
 $tcp_defer_accept_opts = nil
 $tcp_cork_opts = nil
 
 context "Rack::Handler::Mongrel" do
   include TestRequest::Helpers
-  
+
   setup do
     server = Mongrel::HttpServer.new(@host='0.0.0.0', @port=9201)
     server.register('/test',
@@ -52,7 +52,7 @@ context "Rack::Handler::Mongrel" do
     response["REQUEST_METHOD"].should.equal "GET"
     response["SCRIPT_NAME"].should.equal "/test"
     response["REQUEST_PATH"].should.equal "/test"
-    response["PATH_INFO"].should.be.nil
+    response["PATH_INFO"].should.be.equal ""
     response["QUERY_STRING"].should.equal ""
     response["test.postdata"].should.equal ""
 
diff --git a/test/spec_rack_webrick.rb b/test/spec_rack_webrick.rb
index 3e63ea63..8951687a 100644
--- a/test/spec_rack_webrick.rb
+++ b/test/spec_rack_webrick.rb
@@ -9,7 +9,7 @@ Thread.abort_on_exception = true
 
 context "Rack::Handler::WEBrick" do
   include TestRequest::Helpers
-  
+
   setup do
     @server = WEBrick::HTTPServer.new(:Host => @host='0.0.0.0',
                                       :Port => @port=9202,
@@ -50,7 +50,7 @@ context "Rack::Handler::WEBrick" do
     response["REQUEST_METHOD"].should.equal "GET"
     response["SCRIPT_NAME"].should.equal "/test"
     response["REQUEST_PATH"].should.equal "/"
-    response["PATH_INFO"].should.be.nil
+    response["PATH_INFO"].should.be.equal ""
     response["QUERY_STRING"].should.equal ""
     response["test.postdata"].should.equal ""
 
@@ -60,7 +60,7 @@ context "Rack::Handler::WEBrick" do
     response["REQUEST_PATH"].should.equal "/"
     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"