diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-12-04 13:39:42 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-12-04 13:39:42 +0100 |
commit | d2e3afceb738af20aeb8e41f9aad12150cf1e8a7 (patch) | |
tree | 91a1ce5bc7fb51be6c3d188aed11552662d6f4bf /module/network/HTTPRequest.py | |
parent | closed #440 (diff) | |
download | pyload-d2e3afceb738af20aeb8e41f9aad12150cf1e8a7.tar.xz |
Better download connection handling: Detect server error earlier, fallback to single connection if possible
Diffstat (limited to 'module/network/HTTPRequest.py')
-rw-r--r-- | module/network/HTTPRequest.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/module/network/HTTPRequest.py b/module/network/HTTPRequest.py index bd8cdd72e..e58fd114e 100644 --- a/module/network/HTTPRequest.py +++ b/module/network/HTTPRequest.py @@ -30,6 +30,7 @@ from module.plugins.Plugin import Abort def myquote(url): return quote(url, safe="%/:=&?~#+!$,;'@()*[]") +bad_headers = range(400, 404) + range(405, 418) + range(500, 506) class BadHeader(Exception): def __init__(self, code, content=""): @@ -211,11 +212,15 @@ class HTTPRequest(): def verifyHeader(self): """ raise an exceptions on bad headers """ code = int(self.c.getinfo(pycurl.RESPONSE_CODE)) - if code in range(400, 404) or code in range(405, 418) or code in range(500, 506): + if code in bad_headers: #404 will NOT raise an exception raise BadHeader(code, self.getResponse()) return code + def checkHeader(self): + """ check if header indicates failure""" + return int(self.c.getinfo(pycurl.RESPONSE_CODE)) not in bad_headers + def getResponse(self): """ retrieve response from string io """ if self.rep is None: return "" |