aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/rewindable_input.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/rewindable_input.rb')
-rw-r--r--actionpack/lib/action_controller/rewindable_input.rb30
1 files changed, 7 insertions, 23 deletions
diff --git a/actionpack/lib/action_controller/rewindable_input.rb b/actionpack/lib/action_controller/rewindable_input.rb
index 058453ea68..36f655c51e 100644
--- a/actionpack/lib/action_controller/rewindable_input.rb
+++ b/actionpack/lib/action_controller/rewindable_input.rb
@@ -3,33 +3,17 @@ module ActionController
class RewindableIO < ActiveSupport::BasicObject
def initialize(io)
@io = io
- end
-
- def read(*args)
- read_original_io
- @io.read(*args)
- end
-
- def rewind
- read_original_io
- @io.rewind
- end
-
- def string
- @string
+ @rewindable = io.is_a?(StringIO)
end
def method_missing(method, *args, &block)
- @io.send(method, *args, &block)
- end
-
- private
- def read_original_io
- unless @string
- @string = @io.read
- @io = StringIO.new(@string)
- end
+ unless @rewindable
+ @io = StringIO.new(@io.read)
+ @rewindable = true
end
+
+ @io.__send__(method, *args, &block)
+ end
end
def initialize(app)