mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
(Bug fix) - reading /parsing request body when on hypercorn (#8734)
* _safe_get_request_parsed_body * use scope on hypercorn * test http parsing utils * ci/cd run again
This commit is contained in:
parent
f6fa2399cc
commit
c0aec0cc5d
3 changed files with 111 additions and 4 deletions
|
@ -62,8 +62,8 @@ async def _read_request_body(request: Optional[Request]) -> Dict:
|
|||
def _safe_get_request_parsed_body(request: Optional[Request]) -> Optional[dict]:
|
||||
if request is None:
|
||||
return None
|
||||
if hasattr(request, "state") and hasattr(request.state, "parsed_body"):
|
||||
return request.state.parsed_body
|
||||
if hasattr(request, "scope") and "parsed_body" in request.scope:
|
||||
return request.scope["parsed_body"]
|
||||
return None
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ def _safe_set_request_parsed_body(
|
|||
try:
|
||||
if request is None:
|
||||
return
|
||||
request.state.parsed_body = parsed_body
|
||||
request.scope["parsed_body"] = parsed_body
|
||||
except Exception as e:
|
||||
verbose_proxy_logger.debug(
|
||||
"Unexpected error setting request parsed body - {}".format(e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue