Extra connection evaluation before putting it back to the pool

Use `urllib3.util.is_connection_dropped` to check that the connection
is fine before putting it back to the pool to be reused later.
This commit is contained in:
Vangelis Banos 2018-03-02 13:26:26 +00:00
parent 9a797fe612
commit 3bb9355662

View File

@ -64,6 +64,7 @@ import urlcanon
import time
import collections
import cProfile
from urllib3.util import is_connection_dropped
class ProxyingRecorder(object):
"""
@ -456,7 +457,7 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
# put it back in the pool to reuse it later.
if prox_rec_res:
prox_rec_res.close()
if connection_is_fine:
if connection_is_fine and not is_connection_dropped(self._remote_server_conn):
self._conn_pool._put_conn(self._remote_server_conn)
else:
self._remote_server_conn.sock.close()