about summary refs log tree commit homepage
path: root/bin
diff options
context:
space:
mode:
authorzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-02-16 06:41:47 +0000
committerzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-02-16 06:41:47 +0000
commit0c11d7cdf74490cd2a81570f15149331596f17b3 (patch)
treeacc6fbcf51e2761523f270120ec772cb6a3726ba /bin
parent615bdc0298de8f35055dd478675210f458d95422 (diff)
downloadunicorn-0c11d7cdf74490cd2a81570f15149331596f17b3.tar.gz
Functioning CGIWrapper that does a better job of dealing with the CGI->Mongrel translation. Still not perfect but testing is on the way.
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@41 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'bin')
-rw-r--r--bin/mongrel_rails62
1 files changed, 1 insertions, 61 deletions
diff --git a/bin/mongrel_rails b/bin/mongrel_rails
index 21492a9..6e0eb71 100644
--- a/bin/mongrel_rails
+++ b/bin/mongrel_rails
@@ -1,69 +1,9 @@
 require 'rubygems'
 require 'mongrel'
-require 'cgi'
 require 'daemons/daemonize'
 require 'mongrel/command'
 
 
-class CGIFixed < ::CGI
-  public :env_table
-  attr_reader :options
-
-  def initialize(request, response, *args)
-    @request = request
-    @response = response
-    @args = *args
-    @input = StringIO.new(request.body)
-    @options = {}
-    super(*args)
-  end
-
-  def header(options = "text/html")
-    if options.class == Hash
-      # passing in a header so need to keep the status around and other options
-      @options = @options.merge(options)
-    else
-      @options["Content-Type"] = options
-    end
-
-    # doing this fakes out the cgi library to think the headers are empty
-    # we then do the real headers in the out function call later
-    ""
-  end
-
-
-  def out(options = "text/html")
-    header(options)
-    @response.start status do |head, out|
-      @options.each {|k,v| head[k.capitalize] = v}
-      out.write(yield || "")
-    end
-  end
-
-  # computes the status once, but lazily so that people who call header twice
-  # don't get penalized
-  def status
-    if not @status
-      @status = @options["Status"] || @options["status"]
-      
-      if @status
-        @status[0 ... @status.index(' ')] || "200"
-      else
-        @status = "200"
-      end
-    end
-  end    
-
-  def args
-    @args
-  end
-  
-  def env_table
-    @request.params
-  end
-end
-
-
 class RailsHandler < Mongrel::HttpHandler
 
   def initialize(dir, mime_map = {})
@@ -81,7 +21,7 @@ class RailsHandler < Mongrel::HttpHandler
     if @files.can_serve(request.params["PATH_INFO"])
       @files.process(request,response)
     else
-      cgi = CGIFixed.new(request, response)
+      cgi = Mongrel::CGIWrapper.new(request, response)
 
       begin
         @guard.synchronize do