summary refs log tree commit diff
path: root/synapse/http/client.py
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@matrix.org>2016-04-03 12:56:29 +0100
committerMatthew Hodgson <matthew@matrix.org>2016-04-03 12:56:29 +0100
commit8b98a7e8c37f0fae09f33a6d93953584288ed394 (patch)
treee1b29bdaf1a0fa2398b4365fffa7adff376155e0 /synapse/http/client.py
parentfix etag typing error. fix timestamp typing error (diff)
downloadsynapse-8b98a7e8c37f0fae09f33a6d93953584288ed394.tar.xz
pep8
Diffstat (limited to 'synapse/http/client.py')
-rw-r--r--synapse/http/client.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/synapse/http/client.py b/synapse/http/client.py
index f42a36ffa6..442b4bb73d 100644
--- a/synapse/http/client.py
+++ b/synapse/http/client.py
@@ -15,7 +15,9 @@
 from OpenSSL import SSL
 from OpenSSL.SSL import VERIFY_NONE
 
-from synapse.api.errors import CodeMessageException
+from synapse.api.errors import (
+    CodeMessageException, SynapseError, Codes,
+)
 from synapse.util.logcontext import preserve_context_over_fn
 import synapse.metrics
 
@@ -268,7 +270,7 @@ class SimpleHttpClient(object):
         if 'Content-Length' in headers and headers['Content-Length'] > max_size:
             logger.warn("Requested URL is too large > %r bytes" % (self.max_size,))
             # XXX: do we want to explicitly drop the connection here somehow? if so, how?
-            raise # what should we be raising here?
+            raise  # what should we be raising here?
 
         if response.code > 299:
             logger.warn("Got %d when downloading %s" % (response.code, url))
@@ -331,6 +333,7 @@ def _readBodyToFile(response, stream, max_size):
     response.deliverBody(_ReadBodyToFileProtocol(stream, d, max_size))
     return d
 
+
 class CaptchaServerHttpClient(SimpleHttpClient):
     """
     Separate HTTP client for talking to google's captcha servers
@@ -360,6 +363,7 @@ class CaptchaServerHttpClient(SimpleHttpClient):
             # twisted dislikes google's response, no content length.
             defer.returnValue(e.response)
 
+
 class SpiderHttpClient(SimpleHttpClient):
     """
     Separate HTTP client for spidering arbitrary URLs.
@@ -376,8 +380,10 @@ class SpiderHttpClient(SimpleHttpClient):
             connectTimeout=15,
             contextFactory=hs.get_http_client_context_factory()
         )), [('gzip', GzipDecoder)])
-        # Look like Chrome for now
-        #self.user_agent = ("Mozilla/5.0 (%s) (KHTML, like Gecko) Chrome Safari" % hs.version_string)
+        # We could look like Chrome:
+        # self.user_agent = ("Mozilla/5.0 (%s) (KHTML, like Gecko)
+        #                   Chrome Safari" % hs.version_string)
+
 
 def encode_urlencode_args(args):
     return {k: encode_urlencode_arg(v) for k, v in args.items()}