Skip to content

fix(fixRequestBody): support text/plain - #1103

Merged
chimurai merged 2 commits into
chimurai:masterfrom
knudtty:knudtty/text-plain-fix-request-body
Apr 17, 2025
Merged

fix(fixRequestBody): support text/plain#1103
chimurai merged 2 commits into
chimurai:masterfrom
knudtty:knudtty/text-plain-fix-request-body

Conversation

@knudtty

@knudtty knudtty commented Apr 16, 2025

Copy link
Copy Markdown
Contributor

Description

Adds Content-Type text/plain to bodies that are forwarded w/ fixRequestBody. Crucial since bodyParser handles that content-type.

Motivation and Context

Discovered this issue when a proxy server that was using bodyParser used fixRequestBody to forward bodies over to an API. The API would receive a request with a non-zero Content-Length but an empty body, so the API would be in deadlock trying to read from a stream that never would never have any data.

fixes 1102

How has this been tested?

I added a unit test for this case

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@pkg-pr-new

pkg-pr-new Bot commented Apr 17, 2025

Copy link
Copy Markdown
npm i https://pkg.pr.new/http-proxy-middleware@1103

commit: f58e5ad

@coveralls

coveralls commented Apr 17, 2025

Copy link
Copy Markdown

Coverage Status

coverage: 97.129% (+0.01%) from 97.115%
when pulling f58e5ad on knudtty:knudtty/text-plain-fix-request-body
into cf72bcd on chimurai:master.

@chimurai chimurai changed the title fix: add text/plain to fixRequestBody fix(fixRequestBody): support text/plain Apr 17, 2025
@chimurai
chimurai enabled auto-merge (squash) April 17, 2025 18:47
@chimurai
chimurai force-pushed the knudtty/text-plain-fix-request-body branch from a218ae8 to f58e5ad Compare April 17, 2025 18:48
@chimurai
chimurai merged commit 9183b8c into chimurai:master Apr 17, 2025
@chimurai

Copy link
Copy Markdown
Owner

Thanks for this PR 🙏

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.

fixRequestBody does not handle Content-Type text/plain, even though bodyParser.text exists

3 participants