mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
test(grayswan): keep volatile header placeholders only when the header is present
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
c6816223a3
commit
98888713e4
1 changed files with 12 additions and 7 deletions
|
|
@ -2,6 +2,7 @@ import json
|
|||
import uuid
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
from types import MappingProxyType
|
||||
from typing import Final
|
||||
|
||||
import yaml
|
||||
|
|
@ -143,16 +144,20 @@ def _chat_provider(message: dict[str, JsonValue]):
|
|||
return _serving_model_probe(respond)
|
||||
|
||||
|
||||
_VOLATILE_HEADERS: Final = MappingProxyType(
|
||||
{
|
||||
"host": "<host>",
|
||||
"content-length": "<length>",
|
||||
"user-agent": "<user-agent>",
|
||||
"accept-encoding": "<accept-encoding>",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def _normalized_generic_body(body: dict[str, JsonValue]) -> dict[str, JsonValue]:
|
||||
headers: Final = body.get("request_headers")
|
||||
normalized_headers: Final = (
|
||||
{
|
||||
**headers,
|
||||
"host": "<host>",
|
||||
"content-length": "<length>",
|
||||
"user-agent": "<user-agent>",
|
||||
"accept-encoding": "<accept-encoding>",
|
||||
}
|
||||
{**headers, **{name: placeholder for name, placeholder in _VOLATILE_HEADERS.items() if name in headers}}
|
||||
if isinstance(headers, dict)
|
||||
else headers
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue