summaryrefslogtreecommitdiffstats
path: root/module/network
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-01-09 13:41:35 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-01-09 13:41:35 +0100
commit0b6f6fd4ec80f8805cfa9135980903f3038f4c49 (patch)
tree7989f1d540d630e629844329817330d5f10d6068 /module/network
parentencoding fix (diff)
downloadpyload-0b6f6fd4ec80f8805cfa9135980903f3038f4c49.tar.xz
closed #213, #212, #101
Diffstat (limited to 'module/network')
-rw-r--r--module/network/HTTPChunk.py15
-rw-r--r--module/network/HTTPDownload.py4
2 files changed, 14 insertions, 5 deletions
diff --git a/module/network/HTTPChunk.py b/module/network/HTTPChunk.py
index f66121880..eb22fa3c8 100644
--- a/module/network/HTTPChunk.py
+++ b/module/network/HTTPChunk.py
@@ -142,21 +142,28 @@ class HTTPChunk(HTTPRequest):
self.c.setopt(pycurl.WRITEFUNCTION, self.writeBody)
self.c.setopt(pycurl.HEADERFUNCTION, self.writeHeader)
+ # request one byte more, since some servers in russia seems to have a defect arihmetic unit
+
if self.resume:
self.fp = open(self.p.info.getChunkName(self.id), "ab")
self.arrived = self.fp.tell()
if self.range:
- print "Chunked resume with range %i-%i" % (self.arrived+self.range[0], self.range[1])
- self.c.setopt(pycurl.RANGE, "%i-%i" % (self.arrived+self.range[0], self.range[1]))
+ #do nothing if chunk already finished
+ if not self.arrived+self.range[0] - self.range[1]: return None
+
+ range = "%i-%i" % (self.arrived+self.range[0], self.range[1]+1)
+ print "Chunked resume with range %s" % range
+ self.c.setopt(pycurl.RANGE, range)
else:
print "Resume File from %i" % self.arrived
self.c.setopt(pycurl.RESUME_FROM, self.arrived)
else:
if self.range:
- print "Chunked with range %i-%i" % self.range
- self.c.setopt(pycurl.RANGE, "%i-%i" % self.range)
+ range = "%i-%i" % (self.range[0], self.range[1]+1)
+ print "Chunked with range %s" % range
+ self.c.setopt(pycurl.RANGE, range)
self.fp = open(self.p.info.getChunkName(self.id), "wb")
diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py
index ecc7f24b8..1c1f53b88 100644
--- a/module/network/HTTPDownload.py
+++ b/module/network/HTTPDownload.py
@@ -146,7 +146,9 @@ class HTTPDownload():
for i in range(1, chunks):
c = HTTPChunk(i, self, self.info.getChunkRange(i), resume)
self.chunks.append(c)
- self.m.add_handle(c.getHandle())
+ handle = c.getHandle()
+ if handle: self.m.add_handle(handle)
+
while 1:
ret, num_handles = self.m.perform()