Kaynağa Gözat

fix: correct wants_json to accept "application/json" format parameter (#1203)

When the query parameter format=application/json was passed, wants_json()
returned False because it only checked `q == "json"`. This caused clients
explicitly requesting JSON via the full MIME type to receive msgpack
responses instead.

Made-with: Cursor
huang yutong 2 hafta önce
ebeveyn
işleme
cea0efb75a
1 değiştirilmiş dosya ile 1 ekleme ve 1 silme
  1. 1 1
      tools/server/api_utils.py

+ 1 - 1
tools/server/api_utils.py

@@ -108,7 +108,7 @@ def wants_json(req):
     """
     q = req.query_params.get("format", "").strip().lower()
     if q in {"json", "application/json", "msgpack", "application/msgpack"}:
-        return q == "json"
+        return q in ("json", "application/json")
     accept = req.headers.get("Accept", "").strip().lower()
     return "application/json" in accept and "application/msgpack" not in accept