From 692d015627ecf03fbc23cfdb4afcf398b9a09a51 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Thu, 12 Jan 2012 17:26:28 +0100 Subject: scripts for testing and syntax unit test --- module/network/HTTPRequest.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'module/network') 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() -- cgit v1.2.3