mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-14 04:09:09 +00:00
Merge b55c09d6fa into d8c0e2c715
This commit is contained in:
commit
fd28f7fc39
1 changed files with 20 additions and 0 deletions
20
litellm/proxy/utils/header_sanitizer.py
Normal file
20
litellm/proxy/utils/header_sanitizer.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
\"\"\"
|
||||
Header sanitization and guard utilities for LiteLLM proxy authentication forwarding.
|
||||
\"\"\"
|
||||
from typing import Dict, Any, Optional
|
||||
|
||||
def sanitize_proxy_headers(headers: Optional[Dict[str, Any]]) -> Dict[str, str]:
|
||||
if not headers:
|
||||
return {}
|
||||
|
||||
sanitized: Dict[str, str] = {}
|
||||
for k, v in headers.items():
|
||||
if k is None:
|
||||
continue
|
||||
key_str = str(k).strip()
|
||||
if not key_str:
|
||||
continue
|
||||
val_str = "" if v is None else str(v).strip()
|
||||
sanitized[key_str] = val_str
|
||||
|
||||
return sanitized
|
||||
Loading…
Add table
Reference in a new issue