Skip to content

Commit a5a3e92

Browse files
committed
Guard RequestBody#to_s rewind call for Rack 3
Rack 3 removed the requirement for rack.input to implement #rewind. Rack::Lint::InputWrapper in Rack 3 only exposes gets, read, each, and close, so calling rewind unconditionally raised NoMethodError on every PUT/POST request, causing WEBrick to return a 500 error.
1 parent 0fca519 commit a5a3e92

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/webmachine/adapters/rack.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,12 @@ def to_s
182182
if @value
183183
@value.join
184184
else
185-
@request.body.rewind
186-
@request.body.read
185+
# Rack 3 removed the requirement for rack.input to implement #rewind
186+
# (Rack::Lint::InputWrapper in Rack 3 does not define it), so guard
187+
# the call to avoid a NoMethodError on every PUT/POST request.
188+
body = @request.body
189+
body.rewind if body.respond_to?(:rewind)
190+
body.read
187191
end
188192
end
189193

0 commit comments

Comments
 (0)