request: rework json parsing for quixote3 (#36515)
This commit is contained in:
parent
7523343893
commit
5f8c243cd0
|
@ -119,14 +119,18 @@ class HTTPRequest(quixote.http_request.HTTPRequest):
|
|||
def process_inputs(self):
|
||||
if self.parsed:
|
||||
return
|
||||
quixote.http_request.HTTPRequest.process_inputs(self)
|
||||
ctype = self.environ.get("CONTENT_TYPE")
|
||||
if ctype:
|
||||
ctype, ctype_params = quixote.http_request.parse_header(ctype)
|
||||
if ctype == 'application/json':
|
||||
self.stdin = self.django_request
|
||||
quixote.http_request.HTTPRequest.process_inputs(self)
|
||||
if ctype == 'application/json':
|
||||
from .misc import json_loads
|
||||
length = int(self.environ.get('CONTENT_LENGTH') or '0')
|
||||
payload = self.django_request.read(length)
|
||||
if six.PY3: # quixote will have consumed the body
|
||||
self.stdin.seek(0)
|
||||
payload = self.stdin.read(length)
|
||||
try:
|
||||
self._json = json_loads(payload)
|
||||
except ValueError as e:
|
||||
|
|
Loading…
Reference in New Issue