diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-01-29 14:55:27 +0000 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-01-29 14:55:27 +0000 |
commit | 9d8f798a3fa0a0a98626218ff1602bf06be0fb82 (patch) | |
tree | 7226008bc691b4599c2c499de63c4bbced486a1b /synapse/http | |
parent | Move bump schema delta (diff) | |
parent | SYN-252: Supply the stream and topological parts in the correct order to the ... (diff) | |
download | synapse-9d8f798a3fa0a0a98626218ff1602bf06be0fb82.tar.xz |
Merge changes from develop
Diffstat (limited to 'synapse/http')
-rw-r--r-- | synapse/http/client.py | 19 | ||||
-rw-r--r-- | synapse/http/server.py | 8 |
2 files changed, 21 insertions, 6 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 diff --git a/synapse/http/server.py b/synapse/http/server.py index 8015a22edf..0f6539e1be 100644 --- a/synapse/http/server.py +++ b/synapse/http/server.py @@ -16,7 +16,7 @@ from synapse.http.agent_name import AGENT_NAME from synapse.api.errors import ( - cs_exception, SynapseError, CodeMessageException + cs_exception, SynapseError, CodeMessageException, UnrecognizedRequestError ) from synapse.util.logcontext import LoggingContext @@ -139,11 +139,7 @@ class JsonResource(HttpServer, resource.Resource): return # Huh. No one wanted to handle that? Fiiiiiine. Send 400. - self._send_response( - request, - 400, - {"error": "Unrecognized request"} - ) + raise UnrecognizedRequestError() except CodeMessageException as e: if isinstance(e, SynapseError): logger.info("%s SynapseError: %s - %s", request, e.code, e.msg) |