diff options
author | Elan Ruusamäe <glen@pld-linux.org> | 2022-02-03 02:35:58 +0200 |
---|---|---|
committer | Elan Ruusamäe <glen@delfi.ee> | 2022-02-03 10:10:06 +0200 |
commit | 9f95928ba52da755c6876f502d055729d6acb2ca (patch) | |
tree | f965feb467bcfc980b5471c860dc262baa68a9ad /requests_cache/cache_keys.py | |
parent | 6faa065d0ab80c9c37f4a94eaed6c41682f360fe (diff) | |
download | requests-cache-9f95928ba52da755c6876f502d055729d6acb2ca.tar.gz |
Skip empty body decode/encode in normalize_json_body
There's no point to decode/encode empty input.
It will always fail and original be returned.
Diffstat (limited to 'requests_cache/cache_keys.py')
-rw-r--r-- | requests_cache/cache_keys.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/requests_cache/cache_keys.py b/requests_cache/cache_keys.py index 2258d49..47de03b 100644 --- a/requests_cache/cache_keys.py +++ b/requests_cache/cache_keys.py @@ -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) |