Class | Mongrel::CGIWrapper |
In: |
lib/mongrel/cgi.rb
|
Parent: | ::CGI |
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 with the 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.
REMOVED_KEYS | = | [ "nph","status","server","connection","type", "charset","length","language","expires"] | these are stripped out of any keys passed to CGIWrapper.header function |
default_really_final | [RW] | Set this to false if you want calls to CGIWrapper.out to not actually send the response until you force it. |
handler | [RW] | |
head | [R] |
Takes an HttpRequest and HttpResponse object, plus any additional arguments normally passed to CGI. These are used internally to create a wrapper around the real CGI while maintaining Mongrel‘s view of the world.
The dumb thing is people can call header or this or both and in any order. So, we just reuse header and then finalize the HttpResponse the right way. Status is taken from the various options and converted to what Mongrel needs via the CGIWrapper.status function.
We also prevent Rails from actually doing the final send by adding a second parameter "really_final". Only Mongrel calls this after Rails is done. Since this will break other frameworks, it defaults to a different setting for rails (false) and (true) for others.