MCPcopy
hub / github.com/encode/httpx / test_deflate

Function test_deflate

tests/test_decoders.py:14–30  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

12
13
14def 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
33def test_zlib():

Callers

nothing calls this directly

Calls 1

flushMethod · 0.45

Tested by

no test coverage detected