examples/tests/test_build_config.py
raw| 1 | #! /usr/bin/env python |
| 2 | # vi:ts=4:et |
| 3 | |
| 4 | import pycurl |
| 5 | import zlib |
| 6 | from io import BytesIO |
| 7 | |
| 8 | c = pycurl.Curl() |
| 9 | c.setopt(c.URL, 'http://pycurl.io') |
| 10 | #c.setopt(c.ENCODING, 'deflate') |
| 11 | c.setopt(c.HTTPHEADER, ['Accept-Encoding: deflate']) |
| 12 | body = BytesIO() |
| 13 | c.setopt(c.WRITEFUNCTION, body.write) |
| 14 | c.perform() |
| 15 | c.close() |
| 16 | |
| 17 | body = body.getvalue() |
| 18 | print(len(body)) |
| 19 | # Content should be deflate-encoded |
| 20 | body = zlib.decompress(body, -zlib.MAX_WBITS) |
| 21 | print(len(body)) |