-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
BrowserKit: 301 redirect forwards POST requests #20924
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
Comments
To me this looks like it was overlooked when the behaviour for 302 and 303 status codes was implemented. On the other hand, changing this behaviour now could be seen as a BC break. Maybe it should be configurable whether or not the request method will be switched to GET (we could then also deprecate not turning that option on). |
@xabbuh I never contributed to the Symfony projet, I don't know how it works. Can I submit a PR? If yes, what behavior should be implemented? I guess the one without the BC break, so a configurable option + depreciation of not turning that option on, in one PR ? |
@jlamur Sorry for not responding earlier. New features and deprecations should always target the |
re #8895 |
This PR was merged into the 3.3-dev branch. Discussion ---------- 301 status code must drop request method to GET. | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | BC breaks? | yes | Tests pass? | yes | Fixed tickets | #20924 | License | MIT [RFC 7231 §6.4.2](https://tools.ietf.org/html/rfc7231#section-6.4.2) states that 301 HTTP Code should forward POST requests to the Location URI. But, it also states that: > For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request. This is the behavior implemented in almost all user agents. However the `BrowserKit` did forward the method to the subsequent request. This PR make the `BrowserKit` change the request method from POST to GET when the response status code is 301. Commits ------- abda966 301 status code must drop request method to GET.
Uh oh!
There was an error while loading. Please reload this page.
As far as I understand, RFC 7231 §6.4.2 states that 301 HTTP Code should forward POST requests to the Location URI.
But, it also states that:
This is the behavior implemented in almost all user agents (Chrome, Firefox, IE, curl, as far as I tested).
However, the BrowserKit is not implemented this way. It forwards the request to the Location URI with the same method as the source one.
The source code related is here: src/Symfony/Component/BrowserKit/Client.php#L477.
As it can break some websites when crawling them, do you think it has to be changed ? Is there a way to force the browser kit to not forward the POST request ?
The text was updated successfully, but these errors were encountered: