From: Fredrik Tolf Date: Wed, 4 Dec 2013 00:04:53 +0000 (+0100) Subject: Decode gzipped pages on the fly in htcache. X-Git-Url: http://dolda2000.com/gitweb/?p=automanga.git;a=commitdiff_plain;h=75efe5bef75cc6a257d97d27f942871118cdbe0d Decode gzipped pages on the fly in htcache. --- diff --git a/manga/htcache.py b/manga/htcache.py index 2f71f9a..4212db3 100644 --- a/manga/htcache.py +++ b/manga/htcache.py @@ -13,6 +13,9 @@ class cache(object): def miss(self, url): s = urllib.urlopen(url) try: + if s.headers.get("content-encoding") == "gzip": + import gzip, StringIO + return gzip.GzipFile(fileobj=StringIO.StringIO(s.read()), mode="r").read() return s.read() finally: s.close()