misc: don't load json input if there's no input stream (#40481)

This commit is contained in:
Frédéric Péters 2020-03-13 16:10:42 +01:00
parent d763b18b60
commit 9ec92726b6
1 changed files with 1 additions and 1 deletions

View File

@ -132,7 +132,7 @@ class HTTPRequest(quixote.http_request.HTTPRequest):
if length and ctype not in ('application/x-www-form-urlencoded', 'multipart/form-data'):
self.stdin = self.django_request
quixote.http_request.HTTPRequest.process_inputs(self)
if ctype == 'application/json':
if ctype == 'application/json' and self.stdin:
from .misc import json_loads
length = int(self.environ.get('CONTENT_LENGTH') or '0')
self.stdin.seek(0) # quixote will have consumed the body