summary refs log tree commit diff
path: root/synapse/http/servlet.py
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2016-03-14 14:36:17 +0000
committerMark Haines <mjark@negativecurvature.net>2016-03-14 14:36:17 +0000
commite462aa97bfb3d05ada56cd725372734f7311a99f (patch)
treeba196ebb4f83dd936661e96b0bcf8f8c5fe8209a /synapse/http/servlet.py
parentMerge pull request #642 from matrix-org/erikj/logout (diff)
parentFix regression where synapse checked whether push rules were valid JSON befor... (diff)
downloadsynapse-e462aa97bfb3d05ada56cd725372734f7311a99f.tar.xz
Merge pull request #644 from matrix-org/markjh/parse_jsonIII
Fix regression where synapse checked whether push rules were valid
Diffstat (limited to 'synapse/http/servlet.py')
-rw-r--r--synapse/http/servlet.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/synapse/http/servlet.py b/synapse/http/servlet.py
index 1996f8b136..1c8bd8666f 100644
--- a/synapse/http/servlet.py
+++ b/synapse/http/servlet.py
@@ -119,13 +119,13 @@ def parse_string(request, name, default=None, required=False,
             return default
 
 
-def parse_json_object_from_request(request):
-    """Parse a JSON object from the body of a twisted HTTP request.
+def parse_json_value_from_request(request):
+    """Parse a JSON value from the body of a twisted HTTP request.
 
     :param request: the twisted HTTP request.
+    :returns: The JSON value.
     :raises
-        SynapseError if the request body couldn't be decoded as JSON or
-            if it wasn't a JSON object.
+        SynapseError if the request body couldn't be decoded as JSON.
     """
     try:
         content_bytes = request.content.read()
@@ -137,6 +137,19 @@ def parse_json_object_from_request(request):
     except simplejson.JSONDecodeError:
         raise SynapseError(400, "Content not JSON.", errcode=Codes.NOT_JSON)
 
+    return content
+
+
+def parse_json_object_from_request(request):
+    """Parse a JSON object from the body of a twisted HTTP request.
+
+    :param request: the twisted HTTP request.
+    :raises
+        SynapseError if the request body couldn't be decoded as JSON or
+            if it wasn't a JSON object.
+    """
+    content = parse_json_value_from_request(request)
+
     if type(content) != dict:
         message = "Content must be a JSON object."
         raise SynapseError(400, message, errcode=Codes.BAD_JSON)