vllm.entrypoints.serve.utils.server_utils ¶
Classes:
-
AuthenticationMiddleware–Pure ASGI middleware that authenticates each request by checking
-
SSEDecoder–Robust Server-Sent Events decoder for streaming responses.
-
XRequestIdMiddleware–Middleware the set's the X-Request-Id header for each response
Functions:
-
get_uvicorn_log_config–Get the uvicorn log config based on the provided arguments.
AuthenticationMiddleware ¶
Pure ASGI middleware that authenticates each request by checking if the Authorization Bearer token exists and equals anyof "{api_key}".
Notes¶
There are two cases in which authentication is skipped: 1. The HTTP method is OPTIONS. 2. The request path doesn't start with GUARDED_PREFIX (e.g. /health).
Source code in vllm/entrypoints/serve/utils/server_utils.py
SSEDecoder ¶
Robust Server-Sent Events decoder for streaming responses.
Methods:
-
add_content–Add content to the buffer.
-
decode_chunk–Decode a chunk of SSE data and return parsed events.
-
extract_content–Extract content from event data.
-
get_complete_content–Get the complete buffered content.
Source code in vllm/entrypoints/serve/utils/server_utils.py
add_content(content) ¶
decode_chunk(chunk) ¶
Decode a chunk of SSE data and return parsed events.
Source code in vllm/entrypoints/serve/utils/server_utils.py
extract_content(event_data) ¶
XRequestIdMiddleware ¶
Middleware the set's the X-Request-Id header for each response to a random uuid4 (hex) value if the header isn't already present in the request, otherwise use the provided request id.
Source code in vllm/entrypoints/serve/utils/server_utils.py
_extract_content_from_chunk(chunk_data) ¶
Extract content from a streaming response chunk.
Source code in vllm/entrypoints/serve/utils/server_utils.py
_log_non_streaming_response(response_body) ¶
Log non-streaming response.
Source code in vllm/entrypoints/serve/utils/server_utils.py
_log_streaming_response(response, response_body) ¶
Log streaming response with robust SSE parsing.
Source code in vllm/entrypoints/serve/utils/server_utils.py
get_uvicorn_log_config(args) ¶
Get the uvicorn log config based on the provided arguments.
Priority: 1. If log_config_file is specified, use it 2. If disable_access_log_for_endpoints is specified, create a config with the access log filter 3. Otherwise, return None (use uvicorn defaults)