From 900bf08fb652183ac9ea33d87735f3a0b4343b21 Mon Sep 17 00:00:00 2001 From: Pablo Hoffman Date: Sat, 11 Feb 2012 20:28:09 -0200 Subject: [PATCH] fixed struct.error on http compression middleware. closes #87 --- scrapy/utils/gz.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scrapy/utils/gz.py b/scrapy/utils/gz.py index d6221da0d..57bcb2d60 100644 --- a/scrapy/utils/gz.py +++ b/scrapy/utils/gz.py @@ -1,3 +1,4 @@ +import struct from cStringIO import StringIO from gzip import GzipFile @@ -13,8 +14,9 @@ def gunzip(data): try: chunk = f.read(8196) output += chunk - except IOError: + except (IOError, struct.error): # complete only if there is some data, otherwise re-raise + # see issue 87 about catching struct.error if output: output += f.extrabuf break