From c7a71cd00c10334d4440a1a8b23b480ac7b987f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=2E=20K=C3=A4rkk=C3=A4inen?= <98187+Tronic@users.noreply.github.com> Date: Sun, 5 Feb 2023 13:29:01 +0000 Subject: [PATCH] Use FALLBACK_ERROR_FORMAT for handlers that return empty() (#2659) Co-authored-by: L. Karkkainen Co-authored-by: Adam Hopkins --- sanic/errorpages.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sanic/errorpages.py b/sanic/errorpages.py index a2d02bf0..6354210a 100644 --- a/sanic/errorpages.py +++ b/sanic/errorpages.py @@ -406,16 +406,13 @@ CONTENT_TYPE_BY_RENDERERS = { v: k for k, v in RENDERERS_BY_CONTENT_TYPE.items() } +# Handler source code is checked for which response types it returns with the +# route error_format="auto" (default) to determine which format to use. RESPONSE_MAPPING = { - "empty": "html", "json": "json", "text": "text", - "raw": "text", "html": "html", - "file": "html", - "file_stream": "text", - "stream": "text", - "redirect": "html", + "JSONResponse": "json", "text/plain": "text", "text/html": "html", "application/json": "json",