Skip to content

Fix request body parsing side effects on Rack env - #456

Open
marksmith wants to merge 1 commit into
mainfrom
fix-request-body-parsing-side-effects
Open

marksmith wants to merge 1 commit into
mainfrom
fix-request-body-parsing-side-effects

Conversation

@marksmith

Copy link
Copy Markdown
Collaborator

Parsing the request body in Rack and Rails consumes rack.input and caches the result on env. On Rack 3.2 and later, a body replaced by a later middleware is ignored and the application uses the result cached by Zen.

This change first makes rack.input rewindable if it is not already, then parses a copy of env and rewinds rack.input, to ensure that env does not have a cached result and the application can still read the full request body.

@marksmith
marksmith requested a review from hansott October 27, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants