diff options
author | Kirill Grushetsky <krommail@gmail.com> | 2015-07-08 17:21:48 +0300 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2016-02-12 12:31:23 +0100 |
commit | a9b663a8fb96f9e21265322f30fa394abc3dc82b (patch) | |
tree | f2000835384b067eb5ad7041538d89ca4e8858d0 | |
parent | 626613ff10789f356a3bb931c2c408a87cbbee3b (diff) | |
download | bottle-a9b663a8fb96f9e21265322f30fa394abc3dc82b.tar.gz |
json for 'application/json-rpc'
Added json property for requests with 'application/json-rpc' content-type.
-rw-r--r-- | bottle.py | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -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 |