From 0c11d7cdf74490cd2a81570f15149331596f17b3 Mon Sep 17 00:00:00 2001 From: zedshaw Date: Thu, 16 Feb 2006 06:41:47 +0000 Subject: 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 --- bin/mongrel_rails | 62 +------------------------------------------------------ 1 file changed, 1 insertion(+), 61 deletions(-) (limited to 'bin') 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 -- cgit v1.2.3-24-ge0c7