Mongrel_raw_output GemPlugin

This GemPlugin allows you to specify a special header, ‘X-Raw-Output’, to make Mongrel output the body of a response as the entire response. This allows you to have full manual control over the http headers and body from any application (Rails, Camping, etc). I’ve found this useful when mocking the full http response of a foreign server when developing and testing bots and scrapers.

In Rails the best way to use raw_output is with a file called mongrel_raw_output.conf in your config directory. Its contents should liik like this:

uri “/”,

:handler => plugin("/handlers/rawoutput"),
:in_front => false

Then start your Mongrel like this:

mongrel_rails start -S config/mongrel_raw_output.conf

In Rails, you can add this method to application.rb

# send the raw text directly to the client def render_raw raw

render :text => raw
headers['X-Raw-Output'] = true

end