summaryrefslogtreecommitdiffstats
path: root/module/network
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-01-22 22:21:23 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-01-22 22:21:23 +0100
commit4dc4268919d29de81679c99173b39529d8e41f44 (patch)
treeacbdf01d0390053bd4c70d075a59ea74f421755c /module/network
parentfixes for chunked download (diff)
downloadpyload-4dc4268919d29de81679c99173b39529d8e41f44.tar.xz
added missing curl.close
Diffstat (limited to 'module/network')
-rw-r--r--module/network/HTTPDownload.py7
-rw-r--r--module/network/HTTPRequest.py4
2 files changed, 9 insertions, 2 deletions
diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py
index 8bc2c7645..5f3302ce2 100644
--- a/module/network/HTTPDownload.py
+++ b/module/network/HTTPDownload.py
@@ -97,6 +97,9 @@ class HTTPDownload():
fo.write(data)
fi.close()
if fo.tell() < self.info.getChunkRange(i)[1]:
+ fo.close()
+ remove(init)
+ self.info.remove() #there are probably invalid chunks
raise Exception("Downloaded content was smaller than expected")
remove(fname) #remove chunk
fo.close()
@@ -230,8 +233,10 @@ class HTTPDownload():
chunk.close()
self.m.remove_handle(chunk.c)
- self.m.close()
self.chunks = []
+ if hasattr(self, "m"):
+ self.m.close()
+ del self.m
if hasattr(self, "cj"):
del self.cj
if hasattr(self, "info"):
diff --git a/module/network/HTTPRequest.py b/module/network/HTTPRequest.py
index e107831cd..fa34ad5b3 100644
--- a/module/network/HTTPRequest.py
+++ b/module/network/HTTPRequest.py
@@ -163,7 +163,8 @@ class HTTPRequest():
""" 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):
- raise BadHeader(code) #404 will NOT raise an exception
+ #404 will NOT raise an exception
+ raise BadHeader(code)
return code
def getResponse(self):
@@ -195,6 +196,7 @@ class HTTPRequest():
if hasattr(self, "cj"):
del self.cj
if hasattr(self, "c"):
+ self.c.close()
del self.c