mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
3030bc90c9
Conflicts: actionpack/lib/action_controller/base.rb actionpack/lib/action_dispatch/http/mime_type.rb actionpack/lib/action_dispatch/http/request.rb actionpack/lib/action_view/base.rb actionpack/lib/action_view/paths.rb actionpack/test/controller/session/cookie_store_test.rb actionpack/test/dispatch/rack_test.rb actionpack/test/dispatch/request_test.rb
28 lines
584 B
Ruby
28 lines
584 B
Ruby
module ActionDispatch
|
|
class RewindableInput
|
|
class RewindableIO < ActiveSupport::BasicObject
|
|
def initialize(io)
|
|
@io = io
|
|
@rewindable = io.is_a?(::StringIO)
|
|
end
|
|
|
|
def method_missing(method, *args, &block)
|
|
unless @rewindable
|
|
@io = ::StringIO.new(@io.read)
|
|
@rewindable = true
|
|
end
|
|
|
|
@io.__send__(method, *args, &block)
|
|
end
|
|
end
|
|
|
|
def initialize(app)
|
|
@app = app
|
|
end
|
|
|
|
def call(env)
|
|
env['rack.input'] = RewindableIO.new(env['rack.input'])
|
|
@app.call(env)
|
|
end
|
|
end
|
|
end
|