class documentation

class ProxyManager(PoolManager): (source)

View In Hierarchy

Behaves just like :class:`PoolManager`, but sends all requests through the defined proxy, using the CONNECT method for HTTPS URLs. :param proxy_url: The URL of the proxy to be used. :param proxy_headers: A dictionary containing headers that will be sent to the proxy. In case of HTTP they are being sent with each request, while in the HTTPS/CONNECT case they are sent only once. Could be used for proxy authentication. :param proxy_ssl_context: The proxy SSL context is used to establish the TLS connection to the proxy when using HTTPS proxies. :param use_forwarding_for_https: (Defaults to False) If set to True will forward requests to the HTTPS proxy to be made on behalf of the client instead of creating a TLS tunnel via the CONNECT method. **Enabling this flag means that request and response headers and content will be visible from the HTTPS proxy** whereas tunneling keeps request and response headers and content private. IP address, target hostname, SNI, and port are always visible to an HTTPS proxy even when this flag is disabled. Example: >>> proxy = urllib3.ProxyManager('http://localhost:3128/') >>> r1 = proxy.request('GET', 'http://google.com/') >>> r2 = proxy.request('GET', 'http://httpbin.org/') >>> len(proxy.pools) 1 >>> r3 = proxy.request('GET', 'https://httpbin.org/') >>> r4 = proxy.request('GET', 'https://twitter.com/') >>> len(proxy.pools) 3

Method __init__ Undocumented
Method connection_from_host Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme.
Method urlopen Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.
Instance Variable proxy Undocumented
Instance Variable proxy_config Undocumented
Instance Variable proxy_headers Undocumented
Instance Variable proxy_ssl_context Undocumented
Method _set_proxy_headers Sets headers needed by proxies: specifically, the Accept and Host headers. Only sets headers not provided by the user.

Inherited from PoolManager:

Method __enter__ Undocumented
Method __exit__ Undocumented
Method clear Empty our store of pools and direct them all to close.
Method connection_from_context Get a :class:`urllib3.connectionpool.ConnectionPool` based on the request context.
Method connection_from_pool_key Get a :class:`urllib3.connectionpool.ConnectionPool` based on the provided pool key.
Method connection_from_url Similar to :func:`urllib3.connectionpool.connection_from_url`.
Instance Variable connection_pool_kw Undocumented
Instance Variable key_fn_by_scheme Undocumented
Instance Variable pool_classes_by_scheme Undocumented
Instance Variable pools Undocumented
Method _merge_pool_kwargs Merge a dictionary of override values for self.connection_pool_kw.
Method _new_pool Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and any additional pool keyword arguments.
Method _proxy_requires_url_absolute_form Indicates if the proxy requires the complete destination URL in the request. Normally this is only needed when not using an HTTP CONNECT tunnel.
Method _validate_proxy_scheme_url_selection Validates that were not attempting to do TLS in TLS connections on Python2 or with unsupported SSL implementations.

Inherited from RequestMethods (via PoolManager):

Method request Make a request using :meth:`urlopen` with the appropriate encoding of ``fields`` based on the ``method`` used.
Method request_encode_body Make a request using :meth:`urlopen` with the ``fields`` encoded in the body. This is useful for request methods like POST, PUT, PATCH, etc.
Method request_encode_url Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc.
Instance Variable headers Undocumented
Class Variable _encode_url_methods Undocumented
def __init__(self, proxy_url, num_pools=10, headers=None, proxy_headers=None, proxy_ssl_context=None, use_forwarding_for_https=False, **connection_pool_kw): (source)
def connection_from_host(self, host, port=None, scheme='http', pool_kwargs=None): (source)

Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is provided, it is merged with the instance's ``connection_pool_kw`` variable and used to create the new connection pool, if one is needed.

def urlopen(self, method, url, redirect=True, **kw): (source)

Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.

proxy_headers = (source)

Undocumented

proxy_ssl_context = (source)

Undocumented

def _set_proxy_headers(self, url, headers=None): (source)

Sets headers needed by proxies: specifically, the Accept and Host headers. Only sets headers not provided by the user.