From 5965362a0f612600840366cbf010643d6bb83d8c Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Thu, 2 Mar 2023 00:14:13 -0500 Subject: [PATCH] title: add 405 and 404 error responses --- core/title.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/title.py b/core/title.py index 6c54450..252a130 100644 --- a/core/title.py +++ b/core/title.py @@ -53,10 +53,13 @@ class TitleServlet(): code = endpoints["game"] if code not in self.title_registry: self.logger.warn(f"Unknown game code {code}") + request.setResponseCode(404) + return b"" index = self.title_registry[code] if not hasattr(index, "render_GET"): self.logger.warn(f"{code} does not dispatch GET") + request.setResponseCode(405) return b"" return index.render_GET(request, endpoints["version"], endpoints["endpoint"]) @@ -65,10 +68,13 @@ class TitleServlet(): code = endpoints["game"] if code not in self.title_registry: self.logger.warn(f"Unknown game code {code}") + request.setResponseCode(404) + return b"" index = self.title_registry[code] if not hasattr(index, "render_POST"): self.logger.warn(f"{code} does not dispatch POST") + request.setResponseCode(405) return b"" return index.render_POST(request, int(endpoints["version"]), endpoints["endpoint"])