diff options
author | Amber Brown <hawkowl@atleastfornow.net> | 2018-09-12 20:16:31 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-12 20:16:31 +1000 |
commit | 8fd93b5eeaeddce16e0b510741dc5d4768cbc78d (patch) | |
tree | 6147991007454bcf8a389f6ce199ad004ed9948e /synapse/crypto/keyclient.py | |
parent | Merge pull request #3845 from matrix-org/erikj/timeout_reads (diff) | |
download | synapse-8fd93b5eeaeddce16e0b510741dc5d4768cbc78d.tar.xz |
Port crypto/ to Python 3 (#3822)
Diffstat (limited to 'synapse/crypto/keyclient.py')
-rw-r--r-- | synapse/crypto/keyclient.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/synapse/crypto/keyclient.py b/synapse/crypto/keyclient.py index e94400b8e2..57d4665e84 100644 --- a/synapse/crypto/keyclient.py +++ b/synapse/crypto/keyclient.py @@ -50,7 +50,7 @@ def fetch_server_key(server_name, tls_client_options_factory, path=KEY_API_V1): defer.returnValue((server_response, server_certificate)) except SynapseKeyClientError as e: logger.warn("Error getting key for %r: %s", server_name, e) - if e.status.startswith("4"): + if e.status.startswith(b"4"): # Don't retry for 4xx responses. raise IOError("Cannot get key for %r" % server_name) except (ConnectError, DomainError) as e: @@ -82,6 +82,12 @@ class SynapseKeyClientProtocol(HTTPClient): self._peer = self.transport.getPeer() logger.debug("Connected to %s", self._peer) + if not isinstance(self.path, bytes): + self.path = self.path.encode('ascii') + + if not isinstance(self.host, bytes): + self.host = self.host.encode('ascii') + self.sendCommand(b"GET", self.path) if self.host: self.sendHeader(b"Host", self.host) |