urllib3 makes multiple mentions to a property on http.client.HTTPConnection called auto_open. The property isn't used much in the current stdlib http.client module, but has some implications for urllib3: mainly that connections may not be re-used based on this value?
In urllib3.connection.py:
# Calls self._set_hostport(), so self.host is
# self._tunnel_host below.
self._tunnel() # type: ignore[attr-defined]
# Mark this connection as not reusable
self.auto_open = 0
In urllib3.connectionpool.py:
conn.close()
if getattr(conn, "auto_open", 1) == 0:
# This is a proxied connection that has been mutated by
# http.client._tunnel() and cannot be reused (since it would
# attempt to bypass the proxy)
conn = None
I suspect that http.client.HTTPConnection._tunnel() in the past may have rewritten .host and .port properties or something like this and this was our method of "guarding" against that? Currently host and port properties on a connection point to the first origin (read: proxy) on a requests' journey to the destination origin.
- What is the intent of this property and it's values?
- Has that intent changed since the original code in urllib3 using the value was written (git blame!)?
- Can we remove our use/dependence on this value?
- Should we write some tests for this value? (We currently have none!!! 😱)
- Can any of these fixes land in 1.26.x?
urllib3 makes multiple mentions to a property on
http.client.HTTPConnectioncalledauto_open. The property isn't used much in the current stdlibhttp.clientmodule, but has some implications for urllib3: mainly that connections may not be re-used based on this value?In
urllib3.connection.py:In
urllib3.connectionpool.py:I suspect that
http.client.HTTPConnection._tunnel()in the past may have rewritten.hostand.portproperties or something like this and this was our method of "guarding" against that? Currentlyhostandportproperties on a connection point to the first origin (read: proxy) on a requests' journey to the destination origin.