Send the correct host header when fetching keys

This commit is contained in:
Erik Johnston 2016-07-21 11:14:54 +01:00
parent e9e3eaa67d
commit 081e5d55e6

View file

@ -79,8 +79,7 @@ class SynapseKeyClientProtocol(HTTPClient):
self.host = None self.host = None
def connectionMade(self): def connectionMade(self):
self.host = self.transport.getHost() logger.debug("Connected to %s", self.transport.getPeer())
logger.debug("Connected to %s", self.host)
self.sendCommand(b"GET", self.path) self.sendCommand(b"GET", self.path)
if self.host: if self.host:
self.sendHeader(b"Host", self.host) self.sendHeader(b"Host", self.host)
@ -124,7 +123,10 @@ class SynapseKeyClientProtocol(HTTPClient):
self.timer.cancel() self.timer.cancel()
def on_timeout(self): def on_timeout(self):
logger.debug("Timeout waiting for response from %s", self.host) logger.debug(
"Timeout waiting for response from %s: %s",
self.host, self.transport.getPeer(),
)
self.errback(IOError("Timeout waiting for response")) self.errback(IOError("Timeout waiting for response"))
self.transport.abortConnection() self.transport.abortConnection()
@ -133,4 +135,5 @@ class SynapseKeyClientFactory(Factory):
def protocol(self): def protocol(self):
protocol = SynapseKeyClientProtocol() protocol = SynapseKeyClientProtocol()
protocol.path = self.path protocol.path = self.path
protocol.path = self.host
return protocol return protocol