def load_form(self, req, schema): """Return form values from the request as a MultiDictProxy.""" # For consistency with other parsers' behavior, don't attempt to # parse if content-type is mismatched. # TODO: Make this check more specific if core.is_json(req.content_type): return core.missing return self._makeproxy(req.forms, schema)
def parse_form(self, req, name, field): """Pull a form value from the request.""" # For consistency with other parsers' behavior, don't attempt to # parse if content-type is mismatched. # TODO: Make this check more specific if core.is_json(req.content_type): return core.missing return core.get_value(req.forms, name, field)
def parse_json_body(req): """Return the decoded JSON body from the request.""" content_type = req.headers.get('Content-Type') if content_type and core.is_json(content_type): try: return core.parse_json(req.body) except (TypeError, ValueError): pass return {}
def parse_json_body(req): """Return the decoded JSON body from the request.""" content_type = req.headers.get('Content-Type') if content_type and core.is_json(content_type): try: return core.parse_json(req.body) except (TypeError, ValueError): pass return {}
def parse_json_body(req): """Return the decoded JSON body from the request.""" content_type = req.headers.get("Content-Type") if content_type and core.is_json(content_type): try: return core.parse_json(req.body) except TypeError: pass except json.JSONDecodeError as e: if e.doc == "": return core.missing else: raise return {}
def parse_json(self, req, name, field): """Pull a json value from the request.""" json_data = self._cache.get("json") if json_data is None: if not core.is_json(req.content_type): return core.missing try: self._cache["json"] = json_data = core.parse_json(req.body) except json.JSONDecodeError as e: if e.doc == "": return core.missing else: raise return core.get_value(json_data, name, field, allow_many_nested=True)
def is_json_request(req): content_type = req.get_header('Content-Type') return content_type and core.is_json(content_type)
def is_json_request(req): """check the validity of json via core functionality""" content_type = req.content_type return core.is_json(content_type)
def is_json_request(req): return core.is_json(req.mimetype)
def is_json_request(req): content_type = req.get_header("Content-Type") return content_type and core.is_json(content_type)
def is_json_request(req): content_type = req.content_type return core.is_json(content_type)
def is_json_request(req): content_type = req.headers.get("Content-Type") return content_type is not None and core.is_json(content_type)
def is_json_request(req): return core.is_json(req.headers.get("content-type"))
def is_json_request(req: Request) -> bool: content_type = req.content_type return core.is_json(content_type)
def is_json_request(req: quart.Request): return core.is_json(req.mimetype)
def test_is_json(): assert is_json(None) is False assert is_json("application/json") is True assert is_json("application/xml") is False assert is_json("application/vnd.api+json") is True
def is_json_request(req): return core.is_json(req.content_type)
def is_json_request(req): return core.is_json(req.mimetype)
def is_json_request(req: Request) -> bool: content_type = req.headers.get("content-type") return core.is_json(content_type)
def _raw_load_json(self, req): """Return a json payload from the request for the core parser's load_json.""" if not core.is_json(req.content_type): return core.missing return core.parse_json(req.body)
def is_json_request(req): content_type = req.content_type return core.is_json(content_type)