Fix creation of qemu img

Fix https://github.com/GNS3/gns3-gui/issues/1826
This commit is contained in:
Julien Duponchelle 2017-01-31 15:16:05 +01:00
parent bfbc6ff0be
commit 27a1089806
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -41,16 +41,15 @@ from ..config import Config
def parse_request(request, input_schema, raw):
"""Parse body of request and raise HTTP errors in case of problems"""
content_length = request.content_length
if content_length is not None and content_length > 0 and not raw:
request.json = {}
if not raw:
body = yield from request.read()
try:
request.json = json.loads(body.decode('utf-8'))
except ValueError as e:
request.json = {"malformed_json": body.decode('utf-8')}
raise aiohttp.web.HTTPBadRequest(text="Invalid JSON {}".format(e))
else:
request.json = {}
if body:
try:
request.json = json.loads(body.decode('utf-8'))
except ValueError as e:
request.json = {"malformed_json": body.decode('utf-8')}
raise aiohttp.web.HTTPBadRequest(text="Invalid JSON {}".format(e))
# Parse the query string
if len(request.query_string) > 0: