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

Redirects in the Werkzeug browser retain method, headers and params #14

Closed
jh-sportcaster opened this issue Sep 1, 2017 · 1 comment
Labels

Comments

@jh-sportcaster
Copy link

capybara.werkzeug.browser.Browser._process_and_follow_redirects handles redirects in what I would consider a wrong way. I'm talking specifically about

self._process(method, path, params, headers)

What it does at the moment is to retain basically all data from the original request, except the path, which it overrides. This means that if you for instance make a POST request to a URL, and that URL redirects to another page, the second request will be the same. This is a violation of HTTP/1.1 for the 303 status code (which demands a GET request for the new location), and – worse – inconsistent with how all browsers I know of handle 302 and possibly 301.

Thus, my proposal would be a diff of the following nature:

-                self._process(method, path, params, headers)
+                self._process('GET', path, None, headers)

Whatever params would be needed for the subsequent request would be indicated in the response's Location header.

I am unsure whether headers should be retained in its entirety, but I don't know what would be consistent with browser behaviour.

@elliterate elliterate added the bug label Sep 1, 2017
@elliterate
Copy link
Owner

Thanks for the bug report!

You're spot-on about the need to use GET and exclude the params. The headers should be fine—indeed, necessary—as they're only used internally to specify the Referer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants