summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2022-02-04 15:32:44 -0800
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2022-02-13 12:14:15 +1300
commitded9e8a3b2f3119ebf1ca7993b7def2bd0ff8bce (patch)
tree5b34b0ca662fdf47dac5641e40d3c91c6ec95cb6 /test
parent42aff22f708123839ba706cbe659d108b47c40c7 (diff)
downloadrack-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.rb9
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