1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-08 16:53:23 +00:00

Handles empty responses with gzip/deflate encoding.

Closes #661
This commit is contained in:
Chris Wesseling
2022-10-05 13:08:46 +02:00
committed by Jair Henrique
parent f3f66086a1
commit eb59d871b4
2 changed files with 14 additions and 0 deletions

View File

@@ -150,6 +150,8 @@ def decode_response(response):
"""Returns decompressed body according to encoding using zlib.
to (de-)compress gzip format, use wbits = zlib.MAX_WBITS | 16
"""
if not body:
return ""
if encoding == "gzip":
return zlib.decompress(body, zlib.MAX_WBITS | 16)
else: # encoding == 'deflate'