diff options
Diffstat (limited to 'pyload/network')
-rw-r--r-- | pyload/network/HTTPDownload.py | 9 | ||||
-rw-r--r-- | pyload/network/HTTPRequest.py | 32 | ||||
-rw-r--r-- | pyload/network/RequestFactory.py | 13 | ||||
-rw-r--r-- | pyload/network/XDCCRequest.py | 2 |
4 files changed, 36 insertions, 20 deletions
diff --git a/pyload/network/HTTPDownload.py b/pyload/network/HTTPDownload.py index 50c6b4bdf..3c804c21c 100644 --- a/pyload/network/HTTPDownload.py +++ b/pyload/network/HTTPDownload.py @@ -62,7 +62,7 @@ class HTTPDownload: except IOError: self.info = ChunkInfo(filename) - self.chunkSupport = None + self.chunkSupport = True self.m = pycurl.CurlMulti() #needed for speed calculation @@ -129,7 +129,7 @@ class HTTPDownload: except pycurl.error, e: #code 33 - no resume code = e.args[0] - if code == 33: + if resume is True and code == 33: # try again without resume self.log.debug("Errno 33 -> Restart without resume") @@ -150,6 +150,7 @@ class HTTPDownload: if not resume: self.info.clear() self.info.addChunk("%s.chunk0" % self.filename, (0, 0)) #create an initial entry + self.info.save() self.chunks = [] @@ -163,8 +164,8 @@ class HTTPDownload: chunksDone = set() # list of curl handles that are finished chunksCreated = False done = False - if self.info.getCount() > 1: # This is a resume, if we were chunked originally assume still can - self.chunkSupport = True + if self.info.getCount() is 0: # This is a resume, if we were chunked originally assume still can + self.chunkSupport = False while 1: #need to create chunks diff --git a/pyload/network/HTTPRequest.py b/pyload/network/HTTPRequest.py index 66e355b77..6060cd671 100644 --- a/pyload/network/HTTPRequest.py +++ b/pyload/network/HTTPRequest.py @@ -78,7 +78,7 @@ class HTTPRequest: if hasattr(pycurl, "AUTOREFERER"): self.c.setopt(pycurl.AUTOREFERER, 1) self.c.setopt(pycurl.SSL_VERIFYPEER, 0) - self.c.setopt(pycurl.LOW_SPEED_TIME, 30) + self.c.setopt(pycurl.LOW_SPEED_TIME, 60) self.c.setopt(pycurl.LOW_SPEED_LIMIT, 5) #self.c.setopt(pycurl.VERBOSE, 1) @@ -180,7 +180,7 @@ class HTTPRequest: self.getCookies() - def load(self, url, get={}, post={}, referer=True, cookies=True, just_header=False, multipart=False, decode=False): + def load(self, url, get={}, post={}, referer=True, cookies=True, just_header=False, multipart=False, decode=False, follow_location=True, save_cookies=True): """ load and returns a given page """ self.setRequestContext(url, get, post, referer, cookies, multipart) @@ -189,28 +189,32 @@ class HTTPRequest: self.c.setopt(pycurl.HTTPHEADER, self.headers) - if just_header: + if post: + self.c.setopt(pycurl.POST, 1) + else: + self.c.setopt(pycurl.HTTPGET, 1) + + if not follow_location: self.c.setopt(pycurl.FOLLOWLOCATION, 0) + + if just_header: self.c.setopt(pycurl.NOBODY, 1) - if post: - self.c.setopt(pycurl.POST, 1) - else: - self.c.setopt(pycurl.HTTPGET, 1) - self.c.perform() - rep = self.header + self.c.perform() + rep = self.header if just_header else self.getResponse() + + if not follow_location: self.c.setopt(pycurl.FOLLOWLOCATION, 1) - self.c.setopt(pycurl.NOBODY, 0) - else: - self.c.perform() - rep = self.getResponse() + if just_header: + self.c.setopt(pycurl.NOBODY, 0) self.c.setopt(pycurl.POSTFIELDS, "") self.lastEffectiveURL = self.c.getinfo(pycurl.EFFECTIVE_URL) self.code = self.verifyHeader() - self.addCookies() + if save_cookies: + self.addCookies() if decode: rep = self.decodeResponse(rep) diff --git a/pyload/network/RequestFactory.py b/pyload/network/RequestFactory.py index 6811b11d8..58838e707 100644 --- a/pyload/network/RequestFactory.py +++ b/pyload/network/RequestFactory.py @@ -62,7 +62,18 @@ class RequestFactory: def getURL(self, *args, **kwargs): """ see HTTPRequest for argument list """ - h = HTTPRequest(None, self.getOptions()) + cj = None + + if 'cookies' in kwargs: + if isinstance(kwargs['cookies'], CookieJar): + cj = kwargs['cookies'] + elif isinstance(kwargs['cookies'], list): + cj = CookieJar(None) + for cookie in kwargs['cookies']: + if isinstance(cookie, tuple) and len(cookie) == 3: + cj.setCookie(*cookie) + + h = HTTPRequest(cj, self.getOptions()) try: rep = h.load(*args, **kwargs) finally: diff --git a/pyload/network/XDCCRequest.py b/pyload/network/XDCCRequest.py index b9baa7215..6011061b1 100644 --- a/pyload/network/XDCCRequest.py +++ b/pyload/network/XDCCRequest.py @@ -124,7 +124,7 @@ class XDCCRequest: return filename - def _keepAlive(self, sock, readbuffer): + def _keepAlive(self, sock, *readbuffer): fdset = select([sock], [], [], 0) if sock not in fdset[0]: return |