Skip to content

Commit 8e6be05

Browse files
committed
Drop additional headers on redirect (#12146)
(cherry picked from commit 6e8f393)
1 parent 5d922ee commit 8e6be05

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

aiohttp/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,8 @@ async def _connect_and_send_request(
893893
if url.origin() != redirect_origin:
894894
auth = None
895895
headers.pop(hdrs.AUTHORIZATION, None)
896+
headers.pop(hdrs.COOKIE, None)
897+
headers.pop(hdrs.PROXY_AUTHORIZATION, None)
896898

897899
url = parsed_redirect_url
898900
params = {}

tests/test_client_functional.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3445,6 +3445,8 @@ async def srv_from(request):
34453445
async def srv_to(request):
34463446
assert request.host == url_to.host
34473447
assert "Authorization" not in request.headers, "Header wasn't dropped"
3448+
assert "Proxy-Authorization" not in request.headers
3449+
assert "Cookie" not in request.headers
34483450
return web.Response()
34493451

34503452
server_from = await create_server_for_url_and_handler(url_from, srv_from)
@@ -3487,11 +3489,16 @@ async def close(self):
34873489
resp = await client.get(
34883490
url_from,
34893491
auth=aiohttp.BasicAuth("user", "pass"),
3492+
headers={"Proxy-Authorization": "Basic dXNlcjpwYXNz", "Cookie": "a=b"},
34903493
)
34913494
assert resp.status == 200
34923495
resp = await client.get(
34933496
url_from,
3494-
headers={"Authorization": "Basic dXNlcjpwYXNz"},
3497+
headers={
3498+
"Authorization": "Basic dXNlcjpwYXNz",
3499+
"Proxy-Authorization": "Basic dXNlcjpwYXNz",
3500+
"Cookie": "a=b",
3501+
},
34953502
)
34963503
assert resp.status == 200
34973504

0 commit comments

Comments
 (0)