From 4d129e3da5be96cd44f26a385ee240db65ca3210 Mon Sep 17 00:00:00 2001 From: Alexey Derin Date: Fri, 4 Jun 2021 18:04:22 +0300 Subject: [PATCH 1/2] Allow keep-alive with proxy for message with appropriate header --- aiohttp/connector.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aiohttp/connector.py b/aiohttp/connector.py index 58c528de6fb..999da0e2f41 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -1052,8 +1052,9 @@ async def _create_proxy_connection( # Many HTTP proxies has buggy keepalive support. Let's not # reuse connection but close it after processing every - # response. - proto.force_close() + # response besides request has keep-alive header. + if not req.keep_alive(): + proto.force_close() auth = proxy_req.headers.pop(hdrs.AUTHORIZATION, None) if auth is not None: From ac3a77784b308d5e5b8ee4d46aef6681a3093d9b Mon Sep 17 00:00:00 2001 From: Alexey Derin Date: Fri, 4 Jun 2021 18:42:37 +0300 Subject: [PATCH 2/2] Add changenotes --- CHANGES/5765.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 CHANGES/5765.feature diff --git a/CHANGES/5765.feature b/CHANGES/5765.feature new file mode 100644 index 00000000000..6006d993365 --- /dev/null +++ b/CHANGES/5765.feature @@ -0,0 +1 @@ +Allow keep-alive connection with proxy when client explicitly sets keep-alive header.