diff options
author | Dirk Klimpel <5740567+dklimpel@users.noreply.github.com> | 2021-07-15 11:37:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-15 10:37:08 +0100 |
commit | c7603af1d06d65932c420ae76002b6ed94dbf23c (patch) | |
tree | c67496ab02599f2f2fc134f6c5618dd52dee8470 /synapse/http | |
parent | Fix a number of logged errors caused by remote servers being down. (#10400) (diff) | |
download | synapse-c7603af1d06d65932c420ae76002b6ed94dbf23c.tar.xz |
Allow providing credentials to `http_proxy` (#10360)
Diffstat (limited to 'synapse/http')
-rw-r--r-- | synapse/http/proxyagent.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/synapse/http/proxyagent.py b/synapse/http/proxyagent.py index 7dfae8b786..7a6a1717de 100644 --- a/synapse/http/proxyagent.py +++ b/synapse/http/proxyagent.py @@ -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) |