From d150cae4777ae8722397901eb64f1cd53a74aa91 Mon Sep 17 00:00:00 2001 From: zedshaw Date: Sat, 4 Mar 2006 17:55:39 +0000 Subject: Implemented access to the RailsHandler from inside rails. Closed off the remaining bugs on our tracker. git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@74 19e92222-5c0b-0410-8929-a290d50e31e9 --- lib/mongrel/cgi.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lib/mongrel/cgi.rb') diff --git a/lib/mongrel/cgi.rb b/lib/mongrel/cgi.rb index 3d7d25a..14982e0 100644 --- a/lib/mongrel/cgi.rb +++ b/lib/mongrel/cgi.rb @@ -1,14 +1,28 @@ require 'cgi' module Mongrel - # The beginning of a complete wrapper around Mongrel's internal HTTP processing + # The beginning of a complete wrapper around Mongrel's internal HTTP processing # system but maintaining the original Ruby CGI module. Use this only as a crutch # to get existing CGI based systems working. It should handle everything, but please # notify me if you see special warnings. This work is still very alpha so I need # testers to help work out the various corner cases. + # + # The CGIWrapper.handler attribute is normally not set and is available for + # frameworks that need to get back to the handler. Rails uses this to give + # people access to the RailsHandler#files (DirHandler really) so they can + # look-up paths and do other things withthe files managed there. + # + # In Rails you can get the real file for a request with: + # + # path = @request.cgi.handler.files.can_serve(@request['PATH_INFO']) + # + # Which is ugly but does the job. Feel free to write a Rails helper for that. + # Refer to DirHandler#can_serve for more information on this. class CGIWrapper < ::CGI public :env_table attr_reader :options + attr_reader :handler + attr_writer :handler # these are stripped out of any keys passed to CGIWrapper.header function REMOVED_KEYS = [ "nph","status","server","connection","type", @@ -143,5 +157,6 @@ module Mongrel STDERR.puts "WARNING: Your program is doing something not expected. Please tell Zed that stdoutput was used and what software you are running. Thanks." @response.body end + end end -- cgit v1.2.3-24-ge0c7