Method: Mongrel::CGIWrapper#out
- Defined in:
- lib/mongrel/cgi.rb
#out(options = "text/html", really_final = @default_really_final) ⇒ Object
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.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/mongrel/cgi.rb', line 127 def out( = "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() @response.start status do |head, body| (head) @head.each {|k,v| head[k] = v} body.write(yield || "") end @out_called = true end |