mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 21:34:51 -04:00
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.
This commit is contained in:
parent
0b3fd1401f
commit
8520bc3109
5 changed files with 28 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue