(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:
Ishaan Jaff 2025-02-25 15:18:04 -08:00 committed by GitHub
parent f6fa2399cc
commit c0aec0cc5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 111 additions and 4 deletions

View file

@ -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)