Created
September 28, 2009 12:05
-
-
Save ryanbriones/195369 to your computer and use it in GitHub Desktop.
fix for using mongrel_rails with Rails ~> 2.3.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rewindable_input' | |
ActionController::Dispatcher.middleware.insert_before ActionController::ParamsParser, RewindableInput |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RewindableInput | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
begin | |
env['rack.input'].rewind | |
rescue NoMethodError, Errno::ESPIPE | |
# Handles exceptions raised by input streams that cannot be rewound | |
# such as when using plain CGI under Apache | |
env['rack.input'] = StringIO.new(env['rack.input'].read) | |
end | |
@app.call(env) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment