about summary refs log tree commit homepage
path: root/lib/mongrel/http_request.rb
diff options
context:
space:
mode:
authorIan Ownbey <imownbey@gmail.com>2008-11-22 17:48:36 -0800
committerIan Ownbey <imownbey@gmail.com>2008-11-22 17:48:36 -0800
commita59c388dd518d0b0ff85d0621d3406fcc23d6173 (patch)
tree90113ccbbe60f690ecc4ff91ce867f68b346d0dd /lib/mongrel/http_request.rb
parente25b558ba8d2d6812d490b365539c2a7bf219e12 (diff)
downloadunicorn-a59c388dd518d0b0ff85d0621d3406fcc23d6173.tar.gz
Diffstat (limited to 'lib/mongrel/http_request.rb')
-rw-r--r--lib/mongrel/http_request.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/mongrel/http_request.rb b/lib/mongrel/http_request.rb
index c8d4ce4..8df3a5a 100644
--- a/lib/mongrel/http_request.rb
+++ b/lib/mongrel/http_request.rb
@@ -58,6 +58,25 @@ module Mongrel
       @body.rewind if @body
     end
 
+    # returns an environment which is rackable
+    # http://rack.rubyforge.org/doc/files/SPEC.html
+    def env
+      env = params.clone
+      env.delete "HTTP_CONTENT_TYPE"
+      env.delete "HTTP_CONTENT_LENGTH"
+      env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
+      env.update({"rack.version" => [0,1],
+              "rack.input" => @body,
+              "rack.errors" => STDERR,
+
+              "rack.multithread" => true,
+              "rack.multiprocess" => false, # ???
+              "rack.run_once" => false,
+
+              "rack.url_scheme" => "http",
+            })
+    end
+
     # updates all dispatchers about our progress
     def update_request_progress(clen, total)
       return if @dispatchers.nil? || @dispatchers.empty?
@@ -152,4 +171,4 @@ module Mongrel
       return params
     end
   end
-end \ No newline at end of file
+end