The built-in HTTP Adapter for urllib3. Provides a general-case interface for Requests sessions to contact HTTP and HTTPS urls by implementing the Transport Adapter interface. This class will usually be created by the :class:`Session <Session>` class under the covers. :param poo
| 156 | |
| 157 | |
| 158 | class HTTPAdapter(BaseAdapter): |
| 159 | """The built-in HTTP Adapter for urllib3. |
| 160 | |
| 161 | Provides a general-case interface for Requests sessions to contact HTTP and |
| 162 | HTTPS urls by implementing the Transport Adapter interface. This class will |
| 163 | usually be created by the :class:`Session <Session>` class under the |
| 164 | covers. |
| 165 | |
| 166 | :param pool_connections: The number of urllib3 connection pools to cache. |
| 167 | :param pool_maxsize: The maximum number of connections to save in the pool. |
| 168 | :param max_retries: The maximum number of retries each connection |
| 169 | should attempt. Note, this applies only to failed DNS lookups, socket |
| 170 | connections and connection timeouts, never to requests where data has |
| 171 | made it to the server. By default, Requests does not retry failed |
| 172 | connections. If you need granular control over the conditions under |
| 173 | which we retry a request, import urllib3's ``Retry`` class and pass |
| 174 | that instead. |
| 175 | :param pool_block: Whether the connection pool should block for connections. |
| 176 | |
| 177 | Usage:: |
| 178 | |
| 179 | >>> import requests |
| 180 | >>> s = requests.Session() |
| 181 | >>> a = requests.adapters.HTTPAdapter(max_retries=3) |
| 182 | >>> s.mount('http://', a) |
| 183 | """ |
| 184 | |
| 185 | __attrs__: list[str] = [ |
| 186 | "max_retries", |
| 187 | "config", |
| 188 | "_pool_connections", |
| 189 | "_pool_maxsize", |
| 190 | "_pool_block", |
| 191 | ] |
| 192 | |
| 193 | max_retries: Retry |
| 194 | config: dict[str, Any] |
| 195 | proxy_manager: dict[str, Any] |
| 196 | _pool_connections: int |
| 197 | _pool_maxsize: int |
| 198 | _pool_block: bool |
| 199 | poolmanager: _PoolManager |
| 200 | |
| 201 | def __init__( |
| 202 | self, |
| 203 | pool_connections: int = DEFAULT_POOLSIZE, |
| 204 | pool_maxsize: int = DEFAULT_POOLSIZE, |
| 205 | max_retries: int | Retry = DEFAULT_RETRIES, |
| 206 | pool_block: bool = DEFAULT_POOLBLOCK, |
| 207 | ) -> None: |
| 208 | if max_retries == DEFAULT_RETRIES: |
| 209 | self.max_retries = Retry(0, read=False) |
| 210 | else: |
| 211 | self.max_retries = Retry.from_int(max_retries) |
| 212 | self.config = {} |
| 213 | self.proxy_manager = {} |
| 214 | |
| 215 | super().__init__() |
no outgoing calls