Skip to content
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

fix: 301 and 302 change method to GET #3862

Merged
merged 8 commits into from
Nov 21, 2024
Merged

Conversation

DTrombett
Copy link
Contributor

@DTrombett DTrombett commented Nov 21, 2024

This relates to...

Didn't open an issue before this PR so sorry if this is expected but I could not find any discussion about it.
The redirect handler doesn't change the method to GET when the status code is 301/302 and the original method is POST despite being the standard in fetch spec and browser behavior. Also the HTTP standard mentions this too:

Note: For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request. If this behavior is undesired, the 307 (Temporary Redirect) status code can be used instead.

Rationale

Changes

Method is changed to GET and body is removed when a 301/302 response code is received, aligning with fetch and browser behavior
The tests were updated to reflect this change and the ones specifically about request body/method were updated to use PUT instead

Features

Bug Fixes

Breaking Changes and Deprecations

Status

@ronag ronag requested review from mcollina and metcoder95 November 21, 2024 18:35
@Uzlopak
Copy link
Contributor

Uzlopak commented Nov 21, 2024

semver major?

@ronag
Copy link
Member

ronag commented Nov 21, 2024

IMHO a bug fix @mcollina

lib/handler/redirect-handler.js Outdated Show resolved Hide resolved
@ronag ronag merged commit 0d06552 into nodejs:main Nov 21, 2024
36 checks passed
@DTrombett DTrombett deleted the fix/redirect-method branch November 21, 2024 19:54
@github-actions github-actions bot mentioned this pull request Dec 3, 2024
This was referenced Dec 16, 2024
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.

4 participants