Message163004
The API for the gzip module is convenient for reading gzipped file but is rather awkward for reading bytes downloaded from a socket:
>>> import gzip, io
>>> from urllib.request import urlopen, Request
>>> u = urlopen(Request('http://www.nytimes.com', headers={'Accept-Encoding': 'gzip'}))
>>> content = gzip.GzipFile(fileobj=io.BytesIO(u.read()), mode='rb').read()
It would be better if the last line could be written:
>>> content = gzip.decompress_file(u) |
|
Date |
User |
Action |
Args |
2012-06-17 01:34:39 | rhettinger | set | recipients:
+ rhettinger |
2012-06-17 01:34:39 | rhettinger | set | messageid: <1339896879.03.0.627255791455.issue15087@psf.upfronthosting.co.za> |
2012-06-17 01:34:38 | rhettinger | link | issue15087 messages |
2012-06-17 01:34:37 | rhettinger | create | |
|