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

Form submit redirect #273

Open
Revadike opened this issue Oct 15, 2022 · 5 comments
Open

Form submit redirect #273

Revadike opened this issue Oct 15, 2022 · 5 comments

Comments

@Revadike
Copy link

So, I've noticed weird behavior and I think it's caused by how you handle redirects.
When you make a POST request and the response has a redirect, you make a new request to the redirect URL, however this is again a POST request (with body), while instead it should be a simple GET request.

@Revadike
Copy link
Author

I'm using the require version

@alexghr
Copy link
Owner

alexghr commented Oct 20, 2022

Hey, sorry for the late reply, this got lost in my github inbox.

Is is possible the status code is a 307? The spec for a 307 says the client should use the same method and body to make a request at the new location.

The 307 (Temporary Redirect) status code indicates that the target resource resides temporarily under a different URI and the user agent MUST NOT change the request method if it performs an automatic redirection to that URI.

https://httpwg.org/specs/rfc9110.html#status.307

@Revadike
Copy link
Author

It's 302

@alexghr
Copy link
Owner

alexghr commented Oct 21, 2022

This wrapper doesn't automatically replay requests on redirection, that's all handled by got. For 302, the spec uses "may change to GET" instead of "should" or "must", I guess this was a choice made by got developers to keep the same method for 302s as well.

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.

https://httpwg.org/specs/rfc9110.html#status.302

@Revadike
Copy link
Author

In my case, the site breaks if you redirect using POST instead of GET.

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

No branches or pull requests

2 participants