Location header is parsed unconditionally even when follow_redirects is disabled #3179
Unanswered
d0gkiller87
asked this question in
Potential Issue
Replies: 1 comment
-
|
Proposed PR: #3706 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
When the server responds with a malformed
Locationheader (for example, some misconfigured IIS web server sets it toC:\intput\wwwroot\xxx.aspx) in 30X redirections, httpx will parse it and fails.The problem is that this behavior cannot be disabled by setting
follow_redirectstoFalse.Reproduce Setup
Server (flask)
Client (httpx)
Result
Discussion
Here's the relevant function that handles redirection responses: https://github.com/encode/httpx/blob/0.27.0/httpx/_client.py#L991
As we can see,
follow_redirectsis only used after parsing theLocationheader and checking infinite recursions.In my opinion, if the user decides to handle the redirection manually (i.e. by setting
follow_redirectstoFalse), httpx shouldn't inspect theLocationheader then fails. Any thoughts?Beta Was this translation helpful? Give feedback.
All reactions