MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / json

Method json

21-async/mojifinder/bottle.py:1119–1130  ·  view source on GitHub ↗

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.

(self)

Source from the content-addressed store, hash-verified

1117
1118 @DictProperty('environ', 'bottle.request.json', read_only=True)
1119 def json(self):
1120 ''' If the ``Content-Type`` header is ``application/json``, this
1121 property holds the parsed content of the request body. Only requests
1122 smaller than :attr:`MEMFILE_MAX` are processed to avoid memory
1123 exhaustion. '''
1124 ctype = self.environ.get('CONTENT_TYPE', '').lower().split(';')[0]
1125 if ctype == 'application/json':
1126 b = self._get_body_string()
1127 if not b:
1128 return None
1129 return json_loads(b)
1130 return None
1131
1132 def _iter_body(self, read, bufsize):
1133 maxread = max(0, self.content_length)

Callers 1

get_countryFunction · 0.80

Calls 2

_get_body_stringMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected