Skip to content

fix(fixRequestBody): support text/plain #1103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 17, 2025

Conversation

knudtty
Copy link
Contributor

@knudtty knudtty commented Apr 16, 2025

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.

Copy link

pkg-pr-new bot commented Apr 17, 2025

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

commit: f58e5ad

@coveralls
Copy link

coveralls commented Apr 17, 2025

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
10 checks passed
@chimurai
Copy link
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