diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-01-09 18:43:50 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-01-09 18:43:50 +0100 |
commit | 2d894dc7b43313d021d61ba201d0efa10994c696 (patch) | |
tree | 44dd070745e86b8d7fe1f392e7eb7416baf7ec77 /module/network | |
parent | disabled chunk download for files.mail.ru (diff) | |
download | pyload-2d894dc7b43313d021d61ba201d0efa10994c696.tar.xz |
enabled chunk download for files.mail.ru
Diffstat (limited to 'module/network')
-rw-r--r-- | module/network/HTTPChunk.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/module/network/HTTPChunk.py b/module/network/HTTPChunk.py index 573ed1766..89770769f 100644 --- a/module/network/HTTPChunk.py +++ b/module/network/HTTPChunk.py @@ -142,6 +142,8 @@ 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() @@ -150,7 +152,11 @@ class HTTPChunk(HTTPRequest): #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]) + if self.id == len(self.p.info.chunks) - 1: #as last chunk dont set end range, so we get everything + range = "%i-" % self.range[0] + else: + range = "%i-%i" % (self.arrived + self.range[0], min(self.range[1] + 1, self.p.size - 1)) + print "Chunked resume with range %s" % range self.c.setopt(pycurl.RANGE, range) else: @@ -159,7 +165,11 @@ class HTTPChunk(HTTPRequest): else: if self.range: - range = "%i-%i" % self.range + if self.id == len(self.p.info.chunks) - 1: # see above + range = "%i-" % self.range[0] + else: + range = "%i-%i" % (self.range[0], min(self.range[1] + 1, self.p.size - 1)) + print "Chunked with range %s" % range self.c.setopt(pycurl.RANGE, range) |