code: def parse_request(request, input_schema, raw):
      
  
      request.json = {}
      if not raw:
          body = yield from request.read()
          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:
          for (k, v) in urllib.parse.parse_qs(request.query_string).items():
              request.json[k] = v[0]
  
      if input_schema:
          try:
              jsonschema.validate(request.json, input_schema)
          except jsonschema.ValidationError as e:
              log.error("Invalid input query. JSON schema error: {}".format(e.message))
              raise aiohttp.web.HTTPBadRequest(text="Invalid JSON: {} in schema: {}".format(
                  e.message,
                  json.dumps(e.schema)))
  
      return request
docs: Parse body of request and raise HTTP errors in case of problems