1 parent 0d874bd commit aaf5d5aCopy full SHA for aaf5d5a
1 file changed
ietf/api/views.py
@@ -620,6 +620,9 @@ def _err(code, text):
620
if request.method != "POST":
621
return _err(405, "Method not allowed")
622
623
+ if request.content_type != "application/json":
624
+ return _err(415, "Content-Type must be application/json")
625
+
626
# Validate
627
try:
628
payload = json.loads(request.body)
@@ -628,6 +631,8 @@ def _err(code, text):
631
return _err(400, f"JSON parse error at line {err.lineno} col {err.colno}: {err.msg}")
629
632
except jsonschema.exceptions.ValidationError as err:
630
633
return _err(400, f"JSON schema error at {err.json_path}: {err.message}")
634
+ except Exception:
635
+ return _err(400, "Invalid request format")
636
637
638
message = base64.b64decode(payload["message"], validate=True)
0 commit comments