summary refs log tree commit diff
path: root/synapse/http/client.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-01-28 17:29:30 +0000
committerMark Haines <mark.haines@matrix.org>2015-01-28 17:29:30 +0000
commit9c61556504924a063e7739ba80122c8753aed50c (patch)
treea483e292dfe602f30be1f9f17266a1bd0f88552d /synapse/http/client.py
parentFix Formatting (diff)
parentMerge pull request #36 from matrix-org/device_id_from_access_token (diff)
downloadsynapse-9c61556504924a063e7739ba80122c8753aed50c.tar.xz
Merge branch 'develop' into client_v2_sync
Diffstat (limited to 'synapse/http/client.py')
-rw-r--r--synapse/http/client.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/synapse/http/client.py b/synapse/http/client.py
index 7793bab106..198f575cfa 100644
--- a/synapse/http/client.py
+++ b/synapse/http/client.py
@@ -63,6 +63,25 @@ class SimpleHttpClient(object):
         defer.returnValue(json.loads(body))
 
     @defer.inlineCallbacks
+    def post_json_get_json(self, uri, post_json):
+        json_str = json.dumps(post_json)
+
+        logger.info("HTTP POST %s -> %s", json_str, uri)
+
+        response = yield self.agent.request(
+            "POST",
+            uri.encode("ascii"),
+            headers=Headers({
+                "Content-Type": ["application/json"]
+            }),
+            bodyProducer=FileBodyProducer(StringIO(json_str))
+        )
+
+        body = yield readBody(response)
+
+        defer.returnValue(json.loads(body))
+
+    @defer.inlineCallbacks
     def get_json(self, uri, args={}):
         """ Get's some json from the given host and path