[yum-commits] urlgrabber/grabber.py

zpavlas at osuosl.org zpavlas at osuosl.org
Wed Oct 31 14:48:51 UTC 2012


 urlgrabber/grabber.py |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit de556102d4d2330b72aff6a636cc10e487ea4037
Author: Zdeněk Pavlas <zpavlas at redhat.com>
Date:   Wed Oct 31 15:27:59 2012 +0100

    Get rid of "HTTP 200 OK" errors.  BZ 871835.
    
    When the server drops connection after sending "HTTP 200 OK",
    pycurl raises error 18 with empty error message.  Urlgrabber
    assumes it's a HTTP error.
    
    Add an explicit check for 2xx codes, and report the underlying
    error instead (Partial file).

diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
index 206609e..74a692c 100644
--- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py
@@ -1457,7 +1457,7 @@ class PyCurlFileObject(object):
             if self._error[0]:
                 errcode = self._error[0]
                 
-            if errcode == 23 and code >= 200 and code < 299:
+            if errcode == 23 and 200 <= code <= 299:
                 # this is probably wrong but ultimately this is what happens
                 # we have a legit http code and a pycurl 'writer failed' code
                 # which almost always means something aborted it from outside
@@ -1511,7 +1511,7 @@ class PyCurlFileObject(object):
                 err.url = errurl
                 raise err
                     
-            elif str(e.args[1]) == '' and self.http_code != 0: # fake it until you make it
+            elif str(e.args[1]) == '' and code and not 200 <= code <= 299:
                 if self.scheme in ['http', 'https']:
                     if self.http_code in responses:
                         resp = responses[self.http_code]


More information about the Yum-commits mailing list