From a2707341d3051238a1eb0c4faefe1a48a8ec3256 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 10 Sep 2026 18:48:00 +1200 Subject: [PATCH 1/2] Respect input body rewind result Assisted-By: devx/b8194217-b20a-4799-b266-4910beb3ee2b --- lib/protocol/rack/input.rb | 5 +---- test/protocol/rack/input.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/protocol/rack/input.rb b/lib/protocol/rack/input.rb index 90ddc48..2c2c3e3 100644 --- a/lib/protocol/rack/input.rb +++ b/lib/protocol/rack/input.rb @@ -60,10 +60,7 @@ def close(error = nil) # # @returns [Boolean] Whether the body could be rewound. def rewind - if @body and @body.respond_to?(:rewind) - # If the body is not rewindable, this will fail. - @body.rewind - + if @body&.rewind @finished = false @closed = false diff --git a/test/protocol/rack/input.rb b/test/protocol/rack/input.rb index a1e6bf0..9425a4d 100644 --- a/test/protocol/rack/input.rb +++ b/test/protocol/rack/input.rb @@ -211,4 +211,16 @@ expect(input).to be(:closed?) end end + + with "non-rewindable body" do + let(:body) {Protocol::HTTP::Body::Readable.new} + + it "does not report a successful rewind" do + expect(input.read).to be == "" + expect(input).to be(:closed?) + + expect(input.rewind).to be == false + expect(input).to be(:closed?) + end + end end From 88128b0db5b72802a757a6712e24b13186514f58 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 10 Sep 2026 18:49:47 +1200 Subject: [PATCH 2/2] Add unreleased note Assisted-By: devx/b8194217-b20a-4799-b266-4910beb3ee2b --- releases.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/releases.md b/releases.md index d7f7c77..c903c8e 100644 --- a/releases.md +++ b/releases.md @@ -1,5 +1,9 @@ # Releases +## Unreleased + + - Respect the result of rewinding the underlying request body. + ## v0.22.1 - Rack 2 should not use `to_ary`.