Skip to content

fix(redirect): remove body headers after POST-to-GET#5551

Merged
mcollina merged 1 commit into
nodejs:mainfrom
Ram-blip:fix/redirect-body-headers
Jul 13, 2026
Merged

fix(redirect): remove body headers after POST-to-GET#5551
mcollina merged 1 commit into
nodejs:mainfrom
Ram-blip:fix/redirect-body-headers

Conversation

@Ram-blip

Copy link
Copy Markdown
Contributor

This relates to...

RedirectHandler converts POST requests to GET for 301 and 302 redirects and removes the request body, but it currently keeps body-related Content-* headers on the redirected request.

For example, a redirected bodyless GET can still include Content-Type: application/json and Content-Language: en.

Rationale

Headers describing the original request body should not be forwarded after the redirect changes the method to GET and removes the body.

This change applies the existing content-header cleanup used for 303 redirects when a 301 or 302 redirect converts POST to GET.

Changes

Features

N/A

Bug Fixes

  • Remove Content-* headers when a 301 or 302 redirect changes POST to GET.
  • Preserve unrelated request headers.
  • Add a regression test covering the behavior through Client, Pool, and Agent.

Breaking Changes and Deprecations

None.

Status

Signed-off-by: Ram-blip <ramcruze2000@gmail.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.44%. Comparing base (197a83d) to head (e1f242c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5551   +/-   ##
=======================================
  Coverage   93.44%   93.44%           
=======================================
  Files         110      110           
  Lines       37443    37446    +3     
=======================================
+ Hits        34987    34992    +5     
+ Misses       2456     2454    -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina mcollina 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

@mcollina
mcollina merged commit 9780a5a into nodejs:main Jul 13, 2026
33 of 36 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 20, 2026
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