Skip to content

Commit

Permalink
Skip empty body decode/encode in normalize_json_body
Browse files Browse the repository at this point in the history
There's no point to decode/encode empty input.
It will always fail and original be returned.
  • Loading branch information
glensc committed Feb 3, 2022
1 parent 6faa065 commit 9f95928
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions requests_cache/cache_keys.py
Expand Up @@ -161,6 +161,10 @@ def normalize_json_body(
original_body: Union[str, bytes], ignored_parameters: ParamList
) -> Union[str, bytes]:
"""Normalize and filter a request body with serialized JSON data"""

if len(original_body) == 0:
return original_body

try:
body = json.loads(decode(original_body))
body = filter_sort_dict(body, ignored_parameters)
Expand Down

0 comments on commit 9f95928

Please sign in to comment.