requests . adapters . HTTPAdapter
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 Session class under the covers.
>>> import requests >>> s = requests.Session() >>> a = requests.adapters.HTTPAdapter(max_retries=3) >>> s.mount('http://', a)
Parameters | |
pool_connections | The number of urllib3 connection pools to cache. |
pool_maxsize | The maximum number of connections to save in the pool. |
max_retries | The maximum number of retries each connection should attempt. Note, this applies only to failed DNS lookups, socket connections and connection timeouts, never to requests where data has made it to the server. By default, Requests does not retry failed connections. If you need granular control over the conditions under which we retry a request, import urllib3’s Retry class and pass that instead. |
pool_block | Whether the connection pool should block for connections. |
Method | add_headers | Add any headers needed by the connection. As of v2.0 this does nothing by default, but is left for overriding by users that subclass the HTTPAdapter . |
Method | build_response | No summary |
Method | cert_verify | Verify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the HTTPAdapter . |
Method | close | Disposes of any internal state. |
Method | get_connection | Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the HTTPAdapter . |
Method | init_poolmanager | Initializes a urllib3 PoolManager. |
Method | proxy_headers | No summary |
Method | proxy_manager_for | Return urllib3 ProxyManager for the given proxy. |
Method | request_url | Obtain the url to use when making the final request. |
Method | send | Sends PreparedRequest object. Returns Response object. |
Method | __getstate__ | Undocumented |
Method | __init__ | Undocumented |
Method | __setstate__ | Undocumented |
Class Variable | __attrs__ | Undocumented |
Instance Variable | _pool_block | Undocumented |
Instance Variable | _pool_connections | Undocumented |
Instance Variable | _pool_maxsize | Undocumented |
Instance Variable | config | Undocumented |
Instance Variable | max_retries | Undocumented |
Instance Variable | poolmanager | Undocumented |
Instance Variable | proxy_manager | Undocumented |
Add any headers needed by the connection. As of v2.0 this does nothing by default, but is left for overriding by users that subclass the HTTPAdapter .
This should not be called from user code, and is only exposed for use when subclassing the HTTPAdapter .
Parameters | |
request | The PreparedRequest to add headers to. |
**kwargs | The keyword arguments from the call to send(). |
Builds a Response object from a urllib3 response. This should not be called from user code, and is only exposed for use when subclassing the HTTPAdapter
Parameters | |
req | The PreparedRequest used to generate the response. |
resp | The urllib3 response object. |
Returns | |
requests.Response | Undocumented |
Verify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the HTTPAdapter .
Parameters | |
conn | The urllib3 connection object associated with the cert. |
url | The requested URL. |
verify | Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use |
cert | The SSL certificate to verify. |
Disposes of any internal state.
Currently, this closes the PoolManager and any active ProxyManager, which closes any pooled connections.
Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the HTTPAdapter .
Parameters | |
url | The URL to connect to. |
proxies | (optional) A Requests-style dictionary of proxies used on this request. |
Returns | |
urllib3.ConnectionPool | Undocumented |
Initializes a urllib3 PoolManager.
This method should not be called from user code, and is only exposed for use when subclassing the HTTPAdapter .
Parameters | |
connections | The number of urllib3 connection pools to cache. |
maxsize | The maximum number of connections to save in the pool. |
block | Block when no free connections are available. |
**pool_kwargs | Extra keyword arguments used to initialize the Pool Manager. |
Returns a dictionary of the headers to add to any request sent through a proxy. This works with urllib3 magic to ensure that they are correctly sent to the proxy, rather than in a tunnelled request if CONNECT is being used.
This should not be called from user code, and is only exposed for use when subclassing the HTTPAdapter .
Parameters | |
proxy | The url of the proxy being used for this request. |
Returns | |
dict | Undocumented |
Return urllib3 ProxyManager for the given proxy.
This method should not be called from user code, and is only exposed for use when subclassing the HTTPAdapter .
Parameters | |
proxy | The proxy to return a urllib3 ProxyManager for. |
**proxy_kwargs | Extra keyword arguments used to configure the Proxy Manager. |
Returns | |
urllib3.ProxyManager | ProxyManager |
Obtain the url to use when making the final request.
If the message is being sent through a HTTP proxy, the full URL has to be used. Otherwise, we should only use the path portion of the URL.
This should not be called from user code, and is only exposed for use when subclassing the HTTPAdapter .
Parameters | |
request | The PreparedRequest being sent. |
proxies | A dictionary of schemes or schemes and hosts to proxy URLs. |
Returns | |
str | Undocumented |
Sends PreparedRequest object. Returns Response object.
Parameters | |
request | The PreparedRequest being sent. |
stream | (optional) Whether to stream the request content. |
timeout: float or tuple or urllib3 Timeout object | (optional) How long to wait for the server to send data before giving up, as a float, or a :ref:`(connect timeout, read timeout) ` tuple. |
verify | (optional) Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use |
cert | (optional) Any user-provided SSL certificate to be trusted. |
proxies | (optional) The proxies dictionary to apply to the request. |
Returns | |
requests.Response | Undocumented |