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