Skip to content

Commit 6e8f393

Browse files
Drop additional headers on redirect (#12146)
1 parent c0f1513 commit 6e8f393

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

aiohttp/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,8 @@ async def _connect_and_send_request(
880880
):
881881
auth = None
882882
headers.pop(hdrs.AUTHORIZATION, None)
883+
headers.pop(hdrs.COOKIE, None)
884+
headers.pop(hdrs.PROXY_AUTHORIZATION, None)
883885

884886
url = parsed_redirect_url
885887
params = {}

tests/test_client_functional.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3423,8 +3423,12 @@ async def srv_to(request: web.Request) -> web.Response:
34233423
assert request.host == url_to.host
34243424
if is_drop_header_expected:
34253425
assert "Authorization" not in request.headers, "Header wasn't dropped"
3426+
assert "Proxy-Authorization" not in request.headers
3427+
assert "Cookie" not in request.headers
34263428
else:
34273429
assert "Authorization" in request.headers, "Header was dropped"
3430+
assert "Proxy-Authorization" in request.headers
3431+
assert "Cookie" in request.headers
34283432
return web.Response()
34293433

34303434
server_from = await create_server_for_url_and_handler(url_from, srv_from)
@@ -3473,11 +3477,16 @@ async def close(self) -> None:
34733477
async with client.get(
34743478
url_from,
34753479
auth=aiohttp.BasicAuth("user", "pass"),
3480+
headers={"Proxy-Authorization": "Basic dXNlcjpwYXNz", "Cookie": "a=b"},
34763481
) as resp:
34773482
assert resp.status == 200
34783483
async with client.get(
34793484
url_from,
3480-
headers={"Authorization": "Basic dXNlcjpwYXNz"},
3485+
headers={
3486+
"Authorization": "Basic dXNlcjpwYXNz",
3487+
"Proxy-Authorization": "Basic dXNlcjpwYXNz",
3488+
"Cookie": "a=b",
3489+
},
34813490
) as resp:
34823491
assert resp.status == 200
34833492

0 commit comments

Comments
 (0)