mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 08:16:02 -04:00
Allow providing credentials to http_proxy
(#10360)
This commit is contained in:
parent
7695ca0618
commit
c7603af1d0
3 changed files with 64 additions and 14 deletions
|
@ -117,7 +117,8 @@ class ProxyAgent(_AgentBase):
|
|||
https_proxy = proxies["https"].encode() if "https" in proxies else None
|
||||
no_proxy = proxies["no"] if "no" in proxies else None
|
||||
|
||||
# Parse credentials from https proxy connection string if present
|
||||
# Parse credentials from http and https proxy connection string if present
|
||||
self.http_proxy_creds, http_proxy = parse_username_password(http_proxy)
|
||||
self.https_proxy_creds, https_proxy = parse_username_password(https_proxy)
|
||||
|
||||
self.http_proxy_endpoint = _http_proxy_endpoint(
|
||||
|
@ -189,6 +190,15 @@ class ProxyAgent(_AgentBase):
|
|||
and self.http_proxy_endpoint
|
||||
and not should_skip_proxy
|
||||
):
|
||||
# Determine whether we need to set Proxy-Authorization headers
|
||||
if self.http_proxy_creds:
|
||||
# Set a Proxy-Authorization header
|
||||
if headers is None:
|
||||
headers = Headers()
|
||||
headers.addRawHeader(
|
||||
b"Proxy-Authorization",
|
||||
self.http_proxy_creds.as_proxy_authorization_value(),
|
||||
)
|
||||
# Cache *all* connections under the same key, since we are only
|
||||
# connecting to a single destination, the proxy:
|
||||
pool_key = ("http-proxy", self.http_proxy_endpoint)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue