Skip to content

fix: avoid mutating read options when reading body#742

Open
Phillip9587 wants to merge 1 commit into
expressjs:masterfrom
Phillip9587:read-shared-options
Open

fix: avoid mutating read options when reading body#742
Phillip9587 wants to merge 1 commit into
expressjs:masterfrom
Phillip9587:read-shared-options

Conversation

@Phillip9587

Copy link
Copy Markdown
Member

The parser read options were created once per middleware instance and reused for each request. read() was aliasing that shared object and adding per-request length and encoding fields before passing it to raw-body.

Pass raw-body an explicit rawBodyOptions object containing the per-request values it needs.

The parser read options were created once per middleware instance and reused for each request. `read()` was aliasing that shared object and adding per-request `length` and `encoding` fields before passing it to `raw-body`.

Pass `raw-body` an explicit `rawBodyOptions` object containing the per-request values it needs.

@bjohansebas bjohansebas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

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.

3 participants