diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2019-01-25 12:38:16 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-25 12:38:16 +0000 |
commit | 8520bc3109c2de6175391497941f3fc0b74c08e5 (patch) | |
tree | de56258d663b18f76f7d46b8bc2c7d52099d1fb4 /synapse/http/federation/matrix_federation_agent.py | |
parent | Don't require sqlite3 when using postgres (#4466) (diff) | |
download | synapse-8520bc3109c2de6175391497941f3fc0b74c08e5.tar.xz |
Fix Host header sent by MatrixFederationAgent (#4468)
Move the Host header logic down here so that (a) it is used if we reuse the agent elsewhere, and (b) we can mess about with it with .well-known.
Diffstat (limited to 'synapse/http/federation/matrix_federation_agent.py')
-rw-r--r-- | synapse/http/federation/matrix_federation_agent.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/synapse/http/federation/matrix_federation_agent.py b/synapse/http/federation/matrix_federation_agent.py index 0ec28c6696..1788e9a34a 100644 --- a/synapse/http/federation/matrix_federation_agent.py +++ b/synapse/http/federation/matrix_federation_agent.py @@ -19,6 +19,7 @@ from zope.interface import implementer from twisted.internet import defer from twisted.internet.endpoints import HostnameEndpoint, wrapClientTLS from twisted.web.client import URI, Agent, HTTPConnectionPool +from twisted.web.http_headers import Headers from twisted.web.iweb import IAgent from synapse.http.endpoint import parse_server_name @@ -109,6 +110,15 @@ class MatrixFederationAgent(object): else: target = pick_server_from_list(server_list) + # make sure that the Host header is set correctly + if headers is None: + headers = Headers() + else: + headers = headers.copy() + + if not headers.hasHeader(b'host'): + headers.addRawHeader(b'host', server_name_bytes) + class EndpointFactory(object): @staticmethod def endpointForURI(_uri): |