summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2017-03-14 13:37:36 +0000
committerDavid Baker <dave@matrix.org>2017-03-14 13:37:36 +0000
commit1ece06273e3f288ea3d49f6f8af0dbf62ee5d5b6 (patch)
tree29c05fe31955f9382bed935e51c72c3af3c87e8d
parentMerge pull request #1996 from matrix-org/erikj/fix_current_state (diff)
downloadsynapse-1ece06273e3f288ea3d49f6f8af0dbf62ee5d5b6.tar.xz
Handle PartialDownloadError in CAS login
-rw-r--r--synapse/rest/client/v1/login.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/synapse/rest/client/v1/login.py b/synapse/rest/client/v1/login.py
index 72057f1b0c..34eebe6fd8 100644
--- a/synapse/rest/client/v1/login.py
+++ b/synapse/rest/client/v1/login.py
@@ -33,6 +33,8 @@ from saml2.client import Saml2Client
 
 import xml.etree.ElementTree as ET
 
+from twisted.web.client import PartialDownloadError
+
 
 logger = logging.getLogger(__name__)
 
@@ -341,7 +343,12 @@ class CasTicketServlet(ClientV1RestServlet):
             "ticket": request.args["ticket"],
             "service": self.cas_service_url
         }
-        body = yield http_client.get_raw(uri, args)
+        try:
+            body = yield http_client.get_raw(uri, args)
+        except PartialDownloadError as pde:
+            # Twisted raises this error if the connection is closed,
+            # even if that's being used old-http style to signal end-of-data
+            body = pde.response
         result = yield self.handle_cas_response(request, body, client_redirect_url)
         defer.returnValue(result)