-
-
Notifications
You must be signed in to change notification settings - Fork 845
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
Switch follow redirects default #1808
Conversation
I think I like the "explicit better than implicit" vibe to this. At the same time I wonder about usability. But isn't there precedent to this anyway? Doesn't cURL ignore redirects and return 3xx by default too? I think so? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm enjoying the clearer follow_* name as well.
@@ -34,7 +34,7 @@ def request( | |||
auth: AuthTypes = None, | |||
proxies: ProxiesTypes = None, | |||
timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG, | |||
allow_redirects: bool = True, | |||
follow_redirects: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we don't consider a soft deprecation (with a warning) to be worth it here, given the amount of code that would require?
This feels potentially nice, but we need to be careful. Eg. Potentially it changes what expectations you might want on r = httpx.get(...)
r.raise_for_status() # If 3xx responses *aren't* handled by default, then you might want this to raise exceptions for 3xx cases.
data = r.json() Urg. Awkward conflicted imperfect design decisions. Ugh. |
- This is the current behavior in 2021.11 but changed due to a breaking change in httpx see encode/httpx#1808 - Fixes home-assistant#61239
Motivation -- - There is [a breaking change](encode/httpx#1808) replacing `allow_redirects` with `follow_redirects` in `httpx`. - Without changing our test case, it is possible that developers/users can be confused by our code.
Implementation based on discussion #1785.
Switches the auto-redirect behaviour to off by default.
The benefit of this change would be to make it more explicit when redirects should be followed, and avoid code that unintentionally issues multiple requests, as a result of not requesting the correct URL.
We do still allow auto-redirects, but only if explicitly enabled...
Or, by enabling a client-wide default...
Also note that we change
allow_redirects
tofollow_redirects
.This is a big change, but I think it may well be one of those points where it's worth us diverging from requests.
It'd also play more neatly into the behaviour that we'd probably want by default from a command-line client, which I'd really like to see on our roadmap.