From 9c9f6058ce7bb730cfcfd7a204bfc4defb7e64d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 17 Feb 2015 11:50:50 +0100 Subject: [PATCH 1/2] misc: raise an urllib2.HTTPError if get_url returns a non 200 response --- src/authentic2/http_utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/authentic2/http_utils.py b/src/authentic2/http_utils.py index a8f2b26..dd89c2e 100644 --- a/src/authentic2/http_utils.py +++ b/src/authentic2/http_utils.py @@ -30,6 +30,9 @@ def get_url_pycurl(url): c.perform() r = buf.getvalue() buf.close() + http_code = c.getinfo(pycurl.HTTP_CODE) + if http_code != 200: + raise urllib2.HTTPError(url, http_code, None, None, None) return r except pycurl.error, e: # Wrap error -- 2.1.4