[http_server] Let custom /generate routes skip the second contract check (#43114)

This commit is contained in:
shodoco
2026-10-08 11:56:06 -07:00
committed by GitHub
parent 214347891a
commit 1638c5d699
2 changed files with 56 additions and 1 deletions
@@ -914,6 +914,13 @@ async def generate_request(obj: GenerateReqInput, request: Request):
contract_error = generate_contract_error(await request.json())
if contract_error is not None:
return ORJSONResponse(status_code=400, content={"error": contract_error})
return await serve_generate_request(obj, request)
async def serve_generate_request(obj: GenerateReqInput, request: Request):
"""Serve an admitted generate request: `generate_request` after its
contract check. A route that admits requests with its own parser calls
this directly, so the body is not decoded and checked a second time."""
if envs.SGLANG_ENABLE_REQUEST_HEADER_OVERRIDES.get():
apply_header_overrides(obj, request.headers)
if obj.stream: