summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Grushetsky <krommail@gmail.com>2015-07-08 17:21:48 +0300
committerMarcel Hellkamp <marc@gsites.de>2016-02-12 12:31:23 +0100
commita9b663a8fb96f9e21265322f30fa394abc3dc82b (patch)
treef2000835384b067eb5ad7041538d89ca4e8858d0
parent626613ff10789f356a3bb931c2c408a87cbbee3b (diff)
downloadbottle-a9b663a8fb96f9e21265322f30fa394abc3dc82b.tar.gz
json for 'application/json-rpc'
Added json property for requests with 'application/json-rpc' content-type.
-rw-r--r--bottle.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/bottle.py b/bottle.py
index fd560df..e6e5c98 100644
--- a/bottle.py
+++ b/bottle.py
@@ -1269,12 +1269,14 @@ class BaseRequest(object):
@DictProperty('environ', 'bottle.request.json', read_only=True)
def json(self):
- """ If the ``Content-Type`` header is ``application/json``, this
- property holds the parsed content of the request body. Only requests
- smaller than :attr:`MEMFILE_MAX` are processed to avoid memory
- exhaustion. Invalid JSON raises a 400 error response. """
+ """ If the ``Content-Type`` header is ``application/json`` or
+ ``application/json-rpc``, this property holds the parsed content
+ of the request body. Only requests smaller than :attr:`MEMFILE_MAX`
+ are processed to avoid memory exhaustion.
+ Invalid JSON raises a 400 error response.
+ """
ctype = self.environ.get('CONTENT_TYPE', '').lower().split(';')[0]
- if ctype == 'application/json':
+ if ctype in ('application/json', 'application/json-rpc'):
b = self._get_body_string()
if not b:
return None