mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
FIx test_read_request*
This commit is contained in:
parent
fa6f30bdbc
commit
06a65e9c44
1 changed files with 4 additions and 2 deletions
|
|
@ -143,7 +143,8 @@ def _safe_get_request_headers(request: Optional[Request]) -> dict:
|
|||
"""
|
||||
if request is None:
|
||||
return {}
|
||||
cached = getattr(request.state, "_cached_headers", None)
|
||||
state = getattr(request, "state", None)
|
||||
cached = getattr(state, "_cached_headers", None)
|
||||
if cached is not None:
|
||||
return cached
|
||||
try:
|
||||
|
|
@ -154,7 +155,8 @@ def _safe_get_request_headers(request: Optional[Request]) -> dict:
|
|||
)
|
||||
headers = {}
|
||||
try:
|
||||
request.state._cached_headers = headers
|
||||
if state is not None:
|
||||
state._cached_headers = headers
|
||||
except Exception:
|
||||
pass # request.state may not be available in all contexts
|
||||
return headers
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue