MCPcopy
hub / github.com/urllib3/urllib3 / HTTPConnection

Class HTTPConnection

src/urllib3/connection.py:82–600  ·  view source on GitHub ↗

Based on :class:`http.client.HTTPConnection` but provides an extra constructor backwards-compatibility layer between older and newer Pythons. Additional keyword parameters are used to configure attributes of the connection. Accepted parameters include: - ``source_address``: Se

Source from the content-addressed store, hash-verified

80
81
82class HTTPConnection(_HTTPConnection):
83 """
84 Based on :class:`http.client.HTTPConnection` but provides an extra constructor
85 backwards-compatibility layer between older and newer Pythons.
86
87 Additional keyword parameters are used to configure attributes of the connection.
88 Accepted parameters include:
89
90 - ``source_address``: Set the source address for the current connection.
91 - ``socket_options``: Set specific options on the underlying socket. If not specified, then
92 defaults are loaded from ``HTTPConnection.default_socket_options`` which includes disabling
93 Nagle's algorithm (sets TCP_NODELAY to 1) unless the connection is behind a proxy.
94
95 For example, if you wish to enable TCP Keep Alive in addition to the defaults,
96 you might pass:
97
98 .. code-block:: python
99
100 HTTPConnection.default_socket_options + [
101 (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
102 ]
103
104 Or you may want to disable the defaults by passing an empty list (e.g., ``[]``).
105 """
106
107 default_port: typing.ClassVar[int] = port_by_scheme["http"] # type: ignore[misc]
108
109 #: Disable Nagle's algorithm by default.
110 #: ``[(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)]``
111 default_socket_options: typing.ClassVar[connection._TYPE_SOCKET_OPTIONS] = [
112 (socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
113 ]
114
115 #: Whether this connection verifies the host's certificate.
116 is_verified: bool = False
117
118 #: Whether this proxy connection verified the proxy host's certificate.
119 # If no proxy is currently connected to the value will be ``None``.
120 proxy_is_verified: bool | None = None
121
122 blocksize: int
123 source_address: tuple[str, int] | None
124 socket_options: connection._TYPE_SOCKET_OPTIONS | None
125
126 _has_connected_to_proxy: bool
127 _response_options: _ResponseOptions | None
128 _tunnel_host: str | None
129 _tunnel_port: int | None
130 _tunnel_scheme: str | None
131
132 def __init__(
133 self,
134 host: str,
135 port: int | None = None,
136 *,
137 timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT,
138 source_address: tuple[str, int] | None = None,
139 blocksize: int = 16384,

Calls

no outgoing calls

Tested by 5

test_url_from_poolMethod · 0.72
test_skip_headerMethod · 0.72
pyodide_testFunction · 0.72