Possible issue with dropping headers on redirect #4568
Labels
bug
client
reproducer: missing
This PR or issue lacks code, which reproduce the problem described or clearly understandable STR
🐞 Summary
We're experiencing this issue and have isolated it to headers (in particular Authorization) being reset when redirected by the server (we're using aiohttp as a client).
💡 To Reproduce
Take the following for example:
In the following example we set the headers on instantiation of ClientSession, we can verify this via breakpoint 1 and looking at
session._default_headers
which will give us<CIMultiDict('Authorization': 'Token BlahBah')>
once past this, the session performs the get request, the payload is sent with headers and the server responds 301 or 302.
The client then chooses to follow the redirect but it appears aiohttp is intentionally dropping the authorization header (see here: https://github.com/aio-libs/aiohttp/blob/master/aiohttp/client.py#L539)
This in turn raises a 401 Unauthorised response.
💡 Expected behavior
I would expect that the headers remain intact when redirecting.
📋 Logs/tracebacks
N/A
📋 Your version of the Python
📋 Your version of the aiohttp/yarl/multidict distributions
📋 Additional context
Using aiohttp as client, communicating with flask fleet.
The text was updated successfully, but these errors were encountered: