From 75efe5bef75cc6a257d97d27f942871118cdbe0d Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Wed, 4 Dec 2013 01:04:53 +0100 Subject: [PATCH] Decode gzipped pages on the fly in htcache. --- manga/htcache.py | 3 +++ 1 file changed, 3 insertions(+) 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() -- 2.11.0