Do better content negotiation: prefer 'Accept' to 'Content-Type'.
HEAD main1 files changed, 3 insertions, 2 deletions
diff --git a/gn_auth/errors/common.py b/gn_auth/errors/common.py
index 8dc0373..35e4d21 100644
--- a/gn_auth/errors/common.py
+++ b/gn_auth/errors/common.py
@@ -30,10 +30,11 @@ def build_handler(description: str) -> Callable[[Exception], Response]:
"""Generic utility to build error handlers."""
def __handler__(exc: Exception) -> Response:
"""Handle the exception as appropriate for requests of different mimetypes."""
+ logger.debug("EXCEPTION: %s", exc, exc_info=True)
error = (exc.name if hasattr(exc, "name") else exc.__class__.__name__)
status_code = __status_code__(exc)
- content_type = request.content_type
- if bool(content_type) and content_type.lower() == "application/json":
+ if ("application/json" in request.headers.get("Accept", "")
+ or "application/json" in request.headers.get("Content-Type", "")):
return make_response((
add_trace(
exc,
|