Deflate encoding may use either 'zlib' or 'deflate' in the wild. https://stackoverflow.com/questions/1838699/how-can-i-decompress-a-gzip-stream-with-zlib#answer-22311297
()
| 12 | |
| 13 | |
| 14 | def test_deflate(): |
| 15 | """ |
| 16 | Deflate encoding may use either 'zlib' or 'deflate' in the wild. |
| 17 | |
| 18 | https://stackoverflow.com/questions/1838699/how-can-i-decompress-a-gzip-stream-with-zlib#answer-22311297 |
| 19 | """ |
| 20 | body = b"test 123" |
| 21 | compressor = zlib.compressobj(9, zlib.DEFLATED, -zlib.MAX_WBITS) |
| 22 | compressed_body = compressor.compress(body) + compressor.flush() |
| 23 | |
| 24 | headers = [(b"Content-Encoding", b"deflate")] |
| 25 | response = httpx.Response( |
| 26 | 200, |
| 27 | headers=headers, |
| 28 | content=compressed_body, |
| 29 | ) |
| 30 | assert response.content == body |
| 31 | |
| 32 | |
| 33 | def test_zlib(): |