MCPcopy
hub / github.com/urllib3/urllib3 / ProxyManager

Class ProxyManager

src/urllib3/poolmanager.py:506–649  ·  view source on GitHub ↗

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 prox

Source from the content-addressed store, hash-verified

504
505
506class ProxyManager(PoolManager):
507 """
508 Behaves just like :class:`PoolManager`, but sends all requests through
509 the defined proxy, using the CONNECT method for HTTPS URLs.
510
511 :param proxy_url:
512 The URL of the proxy to be used.
513
514 :param proxy_headers:
515 A dictionary containing headers that will be sent to the proxy. In case
516 of HTTP they are being sent with each request, while in the
517 HTTPS/CONNECT case they are sent only once. Could be used for proxy
518 authentication.
519
520 :param proxy_ssl_context:
521 The proxy SSL context is used to establish the TLS connection to the
522 proxy when using HTTPS proxies.
523
524 :param use_forwarding_for_https:
525 (Defaults to False) If set to True will forward requests to the HTTPS
526 proxy to be made on behalf of the client instead of creating a TLS
527 tunnel via the CONNECT method. **Enabling this flag means that request
528 and response headers and content will be visible from the HTTPS proxy**
529 whereas tunneling keeps request and response headers and content
530 private. IP address, target hostname, SNI, and port are always visible
531 to an HTTPS proxy even when this flag is disabled.
532
533 :param proxy_assert_hostname:
534 The hostname of the certificate to verify against.
535
536 :param proxy_assert_fingerprint:
537 The fingerprint of the certificate to verify against.
538
539 Example:
540
541 .. code-block:: python
542
543 import urllib3
544
545 proxy = urllib3.ProxyManager("https://localhost:3128/")
546
547 resp1 = proxy.request("GET", "http://google.com/")
548 resp2 = proxy.request("GET", "http://httpbin.org/")
549
550 # One pool was shared by both plain HTTP requests.
551 print(len(proxy.pools))
552 # 1
553
554 resp3 = proxy.request("GET", "https://httpbin.org/")
555 resp4 = proxy.request("GET", "https://twitter.com/")
556
557 # A separate pool was added for each HTTPS target.
558 print(len(proxy.pools))
559 # 3
560
561 """
562
563 def __init__(

Calls

no outgoing calls