Skip to content

Commit f438791

Browse files
Drop additional headers on redirect (#12146) (#12149)
(cherry picked from commit 6e8f393)
1 parent 5d1cd8c commit f438791

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
@@ -926,6 +926,8 @@ async def _connect_and_send_request(
926926
if url.origin() != redirect_origin:
927927
auth = None
928928
headers.pop(hdrs.AUTHORIZATION, None)
929+
headers.pop(hdrs.COOKIE, None)
930+
headers.pop(hdrs.PROXY_AUTHORIZATION, None)
929931

930932
url = parsed_redirect_url
931933
params = {}

tests/test_client_functional.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3458,6 +3458,8 @@ async def srv_from(request):
34583458
async def srv_to(request):
34593459
assert request.host == url_to.host
34603460
assert "Authorization" not in request.headers, "Header wasn't dropped"
3461+
assert "Proxy-Authorization" not in request.headers
3462+
assert "Cookie" not in request.headers
34613463
return web.Response()
34623464

34633465
server_from = await create_server_for_url_and_handler(url_from, srv_from)
@@ -3500,11 +3502,16 @@ async def close(self):
35003502
resp = await client.get(
35013503
url_from,
35023504
auth=aiohttp.BasicAuth("user", "pass"),
3505+
headers={"Proxy-Authorization": "Basic dXNlcjpwYXNz", "Cookie": "a=b"},
35033506
)
35043507
assert resp.status == 200
35053508
resp = await client.get(
35063509
url_from,
3507-
headers={"Authorization": "Basic dXNlcjpwYXNz"},
3510+
headers={
3511+
"Authorization": "Basic dXNlcjpwYXNz",
3512+
"Proxy-Authorization": "Basic dXNlcjpwYXNz",
3513+
"Cookie": "a=b",
3514+
},
35083515
)
35093516
assert resp.status == 200
35103517

0 commit comments

Comments
 (0)