Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Send the correct host header when fetching keys #941

Merged
merged 3 commits into from
Jul 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions synapse/crypto/keyclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ class SynapseKeyClientProtocol(HTTPClient):
def __init__(self):
self.remote_key = defer.Deferred()
self.host = None
self._peer = None

def connectionMade(self):
self.host = self.transport.getHost()
logger.debug("Connected to %s", self.host)
self._peer = self.transport.getPeer()
logger.debug("Connected to %s", self._peer)

self.sendCommand(b"GET", self.path)
if self.host:
self.sendHeader(b"Host", self.host)
Expand Down Expand Up @@ -124,7 +126,10 @@ def handleResponse(self, response_body_bytes):
self.timer.cancel()

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._peer,
)
self.errback(IOError("Timeout waiting for response"))
self.transport.abortConnection()

Expand All @@ -133,4 +138,5 @@ class SynapseKeyClientFactory(Factory):
def protocol(self):
protocol = SynapseKeyClientProtocol()
protocol.path = self.path
protocol.host = self.host
return protocol