Reputation: 1545
I'm getting a response from a server with the gzip encoding, but I can't figure how to decode it.
I tried using the zlib module but i get the error:
zlib.error: Error -3 while decompressing data: incorrect header check
This is my request:
r = requests.post(url=url,headers=headers,auth=auth,data=data)
print r.status_code
print r.headers
print zlib.decompress(r.content)
The print i get is:
200
{'Content-Length': '1232', 'Content-Encoding': 'gzip', 'Accept-Ranges': 'bytes', 'X-Powered-By': 'PHP/5.5.38', 'Vary': 'Accept-Encoding', ...
the error:
Traceback (most recent call last):
File "C:/testing.py", line 27, in <module>
print zlib.decompress(r.content)
zlib.error: Error -3 while decompressing data: incorrect header check
Upvotes: 0
Views: 699
Reputation: 112259
Try zlib.decompress(r.content, 31)
to request gzip decoding instead of zlib decoding.
Upvotes: 1