Skip to content

Commit

Permalink
[3.3] Disable keep-alive when working with proxy (#3070) (#3074)
Browse files Browse the repository at this point in the history
* Disable keep-alive when working with proxy

* Add changenote
(cherry picked from commit 8b9924f)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
  • Loading branch information
asvetlov authored Jun 12, 2018
1 parent b958df4 commit 259db3a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES/3070.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Many HTTP proxies has buggy keepalive support.
Let's not reuse connection but close it after processing every response.
3 changes: 3 additions & 0 deletions aiohttp/client_proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def should_close(self):
self._payload_parser is not None or
len(self) or self._tail)

def force_close(self):
self._should_close = True

def close(self):
transport = self.transport
if transport is not None:
Expand Down
5 changes: 5 additions & 0 deletions aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,11 @@ async def _create_proxy_connection(self, req, traces, timeout):
transport, proto = await self._create_direct_connection(
proxy_req, [], timeout, client_error=ClientProxyConnectionError)

# Many HTTP proxies has buggy keepalive support. Let's not
# reuse connection but close it after processing every
# response.
proto.force_close()

auth = proxy_req.headers.pop(hdrs.AUTHORIZATION, None)
if auth is not None:
if not req.is_ssl():
Expand Down

0 comments on commit 259db3a

Please sign in to comment.