Read gzip request

Hi, I got problem when our client sent compressed payload in gzip

to reproduce, I create json file then compress it using gzip then I sent it through curl
curl -X POST -d @test/payload.json.gz http://localhost:8000

when I try decompress using zlib.decompress, I got this exception
body = zlib.decompress(body_request.body)
zlib.error: Error -3 while decompressing data: incorrect header check

when I switch using gzip, still got exceptions
body = gzip.decompress(body_request.body)
File “/usr/lib/python3.10/gzip.py”, line 557, in decompress
return f.read()
File “/usr/lib/python3.10/gzip.py”, line 301, in read
return self._buffer.read(size)
File “/usr/lib/python3.10/_compression.py”, line 118, in readall
while data := self.read(sys.maxsize):
File “/usr/lib/python3.10/gzip.py”, line 507, in read
raise EOFError("Compressed file ended before the "
EOFError: Compressed file ended before the end-of-stream marker was reached

any suggestions to solve this issue?

Are you sure it’s properly compressed?

Hi, I think it’s properly compressed. And it’s can be decompressed using python gzip module on command line, here’s the screenshot


btw, I use this command to compressed json file

gzip -k payload.json