summaryrefslogtreecommitdiffstats
path: root/module/network/HTTPRequest.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-01-12 17:26:28 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-01-12 17:26:28 +0100
commit692d015627ecf03fbc23cfdb4afcf398b9a09a51 (patch)
tree3a3b65808c37aecd4d270b3d40850ae52f33a355 /module/network/HTTPRequest.py
parentchanged HEAD request (diff)
downloadpyload-692d015627ecf03fbc23cfdb4afcf398b9a09a51.tar.xz
scripts for testing and syntax unit test
Diffstat (limited to 'module/network/HTTPRequest.py')
-rw-r--r--module/network/HTTPRequest.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/module/network/HTTPRequest.py b/module/network/HTTPRequest.py
index 8d65b025f..4684397d9 100644
--- a/module/network/HTTPRequest.py
+++ b/module/network/HTTPRequest.py
@@ -39,7 +39,7 @@ bad_headers = range(400, 404) + range(405, 418) + range(500, 506)
class BadHeader(Exception):
def __init__(self, code, content=""):
- Exception.__init__(self, "Bad server response: %s %s" % (code, responses[int(code)]))
+ Exception.__init__(self, "Bad server response: %s %s" % (code, responses.get(int(code), "Unknown Header")))
self.code = code
self.content = content
@@ -200,12 +200,13 @@ class HTTPRequest():
else:
self.c.setopt(pycurl.CUSTOMREQUEST, "GET")
- self.c.perform()
- rep = self.header
-
- self.c.setopt(pycurl.FOLLOWLOCATION, 1)
- self.c.setopt(pycurl.NOBODY, 0)
- self.c.setopt(pycurl.CUSTOMREQUEST, 0)
+ try:
+ self.c.perform()
+ rep = self.header
+ finally:
+ self.c.setopt(pycurl.FOLLOWLOCATION, 1)
+ self.c.setopt(pycurl.NOBODY, 0)
+ self.c.setopt(pycurl.CUSTOMREQUEST, 0)
else:
self.c.perform()