[Bugfix] Handle content type with optional parameters (#13383)

Signed-off-by: Zifei Tong <zifeitong@gmail.com>
This commit is contained in:
zifeitong 2025-02-18 03:29:13 -08:00 committed by GitHub
parent 435b502a6e
commit d3231cb436
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -258,7 +258,8 @@ async def build_async_engine_client_from_engine_args(
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(";", maxsplit=1)[0]
if media_type != "application/json":
raise HTTPException(
status_code=HTTPStatus.UNSUPPORTED_MEDIA_TYPE,
detail="Unsupported Media Type: Only 'application/json' is allowed"