diff options
author | Jeremy Evans <code@jeremyevans.net> | 2022-02-04 15:32:44 -0800 |
---|---|---|
committer | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2022-02-13 12:14:15 +1300 |
commit | ded9e8a3b2f3119ebf1ca7993b7def2bd0ff8bce (patch) | |
tree | 5b34b0ca662fdf47dac5641e40d3c91c6ec95cb6 /test | |
parent | 42aff22f708123839ba706cbe659d108b47c40c7 (diff) | |
download | rack-ded9e8a3b2f3119ebf1ca7993b7def2bd0ff8bce.tar.gz |
Add Rack::RewindableInput::Middleware
This will automatically wrap rack.input with Rack::RewindableInput,
for compatibility with middleware and applications that expect
rewindable input.
Related to #1148, but this does not contain any SPEC changes. It's
possible for servers targetting Rack 2 compatibility to use this
middleware to implement the compatibility.
Diffstat (limited to 'test')
-rw-r--r-- | test/spec_rewindable_input.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/spec_rewindable_input.rb b/test/spec_rewindable_input.rb index 5c1bf5c9..e672bcbb 100644 --- a/test/spec_rewindable_input.rb +++ b/test/spec_rewindable_input.rb @@ -155,3 +155,12 @@ describe Rack::RewindableInput do include RewindableTest end end + +describe Rack::RewindableInput::Middleware do + it "wraps rack.input in RewindableInput" do + app = proc{|env| [200, {}, [env['rack.input'].class.to_s]]} + app.call('rack.input'=>StringIO.new(''))[2].must_equal ['StringIO'] + app = Rack::RewindableInput::Middleware.new(app) + app.call('rack.input'=>StringIO.new(''))[2].must_equal ['Rack::RewindableInput'] + end +end |