Skip to content

fix(fixRequestBody): support content-encoding on request body#1142

Merged
chimurai merged 2 commits intochimurai:masterfrom
robbtraister:fix-request-body/content-encoding
Apr 3, 2026
Merged

fix(fixRequestBody): support content-encoding on request body#1142
chimurai merged 2 commits intochimurai:masterfrom
robbtraister:fix-request-body/content-encoding

Conversation

@robbtraister
Copy link
Copy Markdown
Contributor

Description

The body-parser package supports the content-encoding header on the request (See here). When reconstructing the body for proxied requests that have already been parsed, we should respect the content-encoding header and preserve the original compression algorithm.

Motivation and Context

Without this patch, an encoded request will fail when the upstream server attempts to read it due to a mismatch between the compression algorithm reported and the actual payload received. An alternative approach would be to remove the content-encoding header from the proxied request, but this seems more appropriate.

How has this been tested?

I added a unit test to verify that the reconstructed body is encoded as expected.

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.

Comment thread src/handlers/fix-request-body.ts Outdated
@chimurai chimurai added this to the v4 milestone Apr 3, 2026
@chimurai chimurai force-pushed the fix-request-body/content-encoding branch from b8e7462 to 78df26d Compare April 3, 2026 22:39
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 3, 2026

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

commit: 80f182f

@chimurai chimurai merged commit d7d7916 into chimurai:master Apr 3, 2026
10 checks passed
@chimurai
Copy link
Copy Markdown
Owner

chimurai commented Apr 3, 2026

Thanks!

@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 95.408% (-0.9%) from 96.335%
when pulling 78df26d on robbtraister:fix-request-body/content-encoding
into b67d34d on chimurai:master.

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