MCPcopy
hub / github.com/psf/requests / proxy_headers

Method proxy_headers

src/requests/adapters.py:613–632  ·  view source on GitHub ↗

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, a

(self, proxy: str)

Source from the content-addressed store, hash-verified

611 pass
612
613 def proxy_headers(self, proxy: str) -> dict[str, str]:
614 """Returns a dictionary of the headers to add to any request sent
615 through a proxy. This works with urllib3 magic to ensure that they are
616 correctly sent to the proxy, rather than in a tunnelled request if
617 CONNECT is being used.
618
619 This should not be called from user code, and is only exposed for use
620 when subclassing the
621 :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
622
623 :param proxy: The url of the proxy being used for this request.
624 :rtype: dict
625 """
626 headers: dict[str, str] = {}
627 username, password = get_auth_from_url(proxy)
628
629 if username:
630 headers["Proxy-Authorization"] = _basic_auth_str(username, password)
631
632 return headers
633
634 def send(
635 self,

Callers 3

proxy_manager_forMethod · 0.95
test_proxy_authMethod · 0.95

Calls 2

get_auth_from_urlFunction · 0.85
_basic_auth_strFunction · 0.85

Tested by 2

test_proxy_authMethod · 0.76