diff options
author | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-08-12 19:47:22 +0000 |
---|---|---|
committer | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-08-12 19:47:22 +0000 |
commit | 7eac06c06da31e4057926cd2a6f03bf2796c4a4f (patch) | |
tree | 8d707476d8e628a1b13b626cdb19c75b7b14884a /lib/mongrel/cgi.rb | |
parent | 4efe29da989a8b1783e7a1261098c346d6370e9e (diff) | |
download | unicorn-7eac06c06da31e4057926cd2a6f03bf2796c4a4f.tar.gz |
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@315 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'lib/mongrel/cgi.rb')
-rw-r--r-- | lib/mongrel/cgi.rb | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/mongrel/cgi.rb b/lib/mongrel/cgi.rb index 0c941b9..a4efaad 100644 --- a/lib/mongrel/cgi.rb +++ b/lib/mongrel/cgi.rb @@ -27,8 +27,10 @@ module Mongrel class CGIWrapper < ::CGI public :env_table attr_reader :options - attr_reader :handler - attr_writer :handler + attr_accessor :handler + # Set this to false if you want calls to CGIWrapper.out to not actually send + # the response until you force it. + attr_accessor :default_really_final # these are stripped out of any keys passed to CGIWrapper.header function REMOVED_KEYS = [ "nph","status","server","connection","type", @@ -44,6 +46,7 @@ module Mongrel @input = request.body @head = {} @out_called = false + @default_really_final=true super(*args) end @@ -116,8 +119,16 @@ module Mongrel # 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. - def out(options = "text/html") - return if @out_called # don't do this more than once + # + # 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. + def out(options = "text/html", really_final=@default_really_final) + if @out_called || !really_final + # don't do it more than once or if it's not the really final call + return + end header(options) |