From 65562331f8407c515b7fde4394a714ccee09eef3 Mon Sep 17 00:00:00 2001 From: Zifei Tong Date: Sun, 16 Feb 2025 23:37:04 -0800 Subject: [PATCH 1/3] Handle content type with optional parameters e.g. application/json; charset=UTF-8 Signed-off-by: Zifei Tong --- vllm/entrypoints/openai/api_server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vllm/entrypoints/openai/api_server.py b/vllm/entrypoints/openai/api_server.py index ad391d6737bf..2bc695789c59 100644 --- a/vllm/entrypoints/openai/api_server.py +++ b/vllm/entrypoints/openai/api_server.py @@ -258,7 +258,8 @@ def _cleanup_ipc_path(): async def validate_json_request(raw_request: Request): content_type = raw_request.headers.get("content-type", "").lower() - if content_type != "application/json": + media_type = content_type.split(",")[0] + if media_type != "application/json": raise HTTPException( status_code=HTTPStatus.UNSUPPORTED_MEDIA_TYPE, detail="Unsupported Media Type: Only 'application/json' is allowed" From e7552b8fff9bcbd36a860e8b8142d9f2333794f1 Mon Sep 17 00:00:00 2001 From: Zifei Tong Date: Mon, 17 Feb 2025 00:31:09 -0800 Subject: [PATCH 2/3] Should be semicolon Signed-off-by: Zifei Tong --- vllm/entrypoints/openai/api_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vllm/entrypoints/openai/api_server.py b/vllm/entrypoints/openai/api_server.py index 2bc695789c59..0a543f96c5b8 100644 --- a/vllm/entrypoints/openai/api_server.py +++ b/vllm/entrypoints/openai/api_server.py @@ -258,7 +258,7 @@ def _cleanup_ipc_path(): async def validate_json_request(raw_request: Request): content_type = raw_request.headers.get("content-type", "").lower() - media_type = content_type.split(",")[0] + media_type = content_type.split(";")[0] if media_type != "application/json": raise HTTPException( status_code=HTTPStatus.UNSUPPORTED_MEDIA_TYPE, From 0a87e6cae75f116b39a325ad0f346c16988b8461 Mon Sep 17 00:00:00 2001 From: Zifei Tong Date: Mon, 17 Feb 2025 22:26:26 -0800 Subject: [PATCH 3/3] Add maxsplit Signed-off-by: Zifei Tong --- vllm/entrypoints/openai/api_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vllm/entrypoints/openai/api_server.py b/vllm/entrypoints/openai/api_server.py index 0a543f96c5b8..8e9355f41bea 100644 --- a/vllm/entrypoints/openai/api_server.py +++ b/vllm/entrypoints/openai/api_server.py @@ -258,7 +258,7 @@ def _cleanup_ipc_path(): async def validate_json_request(raw_request: Request): content_type = raw_request.headers.get("content-type", "").lower() - media_type = content_type.split(";")[0] + media_type = content_type.split(";", maxsplit=1)[0] if media_type != "application/json": raise HTTPException( status_code=HTTPStatus.UNSUPPORTED_MEDIA_TYPE,