changeset 26:52f02c6edfa9

app returns bad request http status if submission isn't json.
author Atul Varma <varmaa@toolness.com>
date Thu, 12 Feb 2009 22:23:10 -0800
parents 0aecc756ea18
children a42400d52a1e
files server.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/server.py	Thu Feb 12 20:06:17 2009 -0800
+++ b/server.py	Thu Feb 12 22:23:10 2009 -0800
@@ -34,7 +34,11 @@
             if cid == status['max_changeset'] + 1:
                 status['max_changeset'] = cid
                 req = atulweb.Request(environ)
-                changeset = req.get_input('application/json')
+                try:
+                    changeset = req.get_input('application/json')
+                except ValueError:
+                    raise atulweb.HttpError('bad request',
+                                            'invalid json data')
                 changesets[cid] = changeset
                 return atulweb.Response('changeset committed.')
             else: