diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-04-30 19:16:47 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-04-30 19:16:47 +0200 |
commit | 6272b848234d63ce193abc6996b2eec9b2af5cb7 (patch) | |
tree | 1f5f963c07fb4d5c3d4a454c40afd4b3025c8b78 /module/network | |
parent | UploadStation & BitshareCom: #295 (diff) | |
download | pyload-6272b848234d63ce193abc6996b2eec9b2af5cb7.tar.xz |
Diffstat (limited to 'module/network')
-rw-r--r-- | module/network/Browser.py | 13 | ||||
-rw-r--r-- | module/network/HTTPDownload.py | 7 | ||||
-rw-r--r-- | module/network/HTTPRequest.py | 1 | ||||
-rw-r--r-- | module/network/RequestFactory.py | 11 |
4 files changed, 17 insertions, 15 deletions
diff --git a/module/network/Browser.py b/module/network/Browser.py index 0bf5cf3cf..9020a6de1 100644 --- a/module/network/Browser.py +++ b/module/network/Browser.py @@ -1,7 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from os.path import join from logging import getLogger from HTTPRequest import HTTPRequest @@ -74,7 +73,7 @@ class Browser(object): self._size = self.dl.size self.dl.abort = True - def httpDownload(self, url, filename, get={}, post={}, ref=True, cookies=True, chunks=1, resume=False, progressNotify=None, disposition=True): + def httpDownload(self, url, filename, get={}, post={}, ref=True, cookies=True, chunks=1, resume=False, progressNotify=None, disposition=False): """ this can also download ftp """ self._size = 0 self.dl = HTTPDownload(url, filename, get, post, self.lastEffectiveURL if ref else None, @@ -87,15 +86,9 @@ class Browser(object): return name - - def download(self, url, file_name, folder, get={}, post={}, ref=True, cookies=True, no_post_encode=False): - self.log.warning("Browser: deprecated call 'download'") - - return self.httpDownload(url, join(folder, file_name), get, post, ref, cookies) - - def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False): + def load(self, *args, **kwargs): """ retrieves page """ - return self.http.load(url, get, post, ref, cookies, just_header) + return self.http.load(*args, **kwargs) def putHeader(self, name, value): diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py index b20f565ea..9d0395c6f 100644 --- a/module/network/HTTPDownload.py +++ b/module/network/HTTPDownload.py @@ -18,7 +18,7 @@ """ from os import remove, fsync -from os.path import dirname, join +from os.path import dirname from time import sleep, time from shutil import move @@ -28,11 +28,12 @@ from HTTPChunk import ChunkInfo, HTTPChunk from HTTPRequest import BadHeader from module.plugins.Plugin import Abort +from module.utils import save_join class HTTPDownload(): """ loads a url http + ftp """ def __init__(self, url, filename, get={}, post={}, referer=None, cj=None, bucket=None, - interface=None, proxies={}, progressNotify=None, disposition=True): + interface=None, proxies={}, progressNotify=None, disposition=False): self.url = url self.filename = filename #complete file destination, not only name self.get = get @@ -110,7 +111,7 @@ class HTTPDownload(): fo.close() if self.nameDisposition and self.disposition: - self.filename = join(dirname(self.filename), self.nameDisposition) + self.filename = save_join(dirname(self.filename), self.nameDisposition) move(init, self.filename) self.info.remove() #remove info file diff --git a/module/network/HTTPRequest.py b/module/network/HTTPRequest.py index 50c09afe2..fa088391a 100644 --- a/module/network/HTTPRequest.py +++ b/module/network/HTTPRequest.py @@ -159,6 +159,7 @@ class HTTPRequest(): self.c.setopt(pycurl.NOBODY, 1) self.c.perform() rep = self.header + else: self.c.perform() rep = self.getResponse() diff --git a/module/network/RequestFactory.py b/module/network/RequestFactory.py index 90a48fe3c..e91b9ea41 100644 --- a/module/network/RequestFactory.py +++ b/module/network/RequestFactory.py @@ -54,6 +54,10 @@ class RequestFactory(): self.lock.release() return req + def getHTTPRequest(self): + """ returns a http request, dont forget to close it ! """ + return HTTPRequest(None, self.iface(), self.getProxies()) + def getURL(self, url, get={}, post={}, multipart=False): h = HTTPRequest(None, self.iface(), self.getProxies()) rep = h.load(url, get, post, multipart=multipart) @@ -76,7 +80,7 @@ class RequestFactory(): type = "http" setting = self.core.config["proxy"]["type"].lower() if setting == "socks4": type = "socks4" - if setting == "socks5": type = "socks5" + elif setting == "socks5": type = "socks5" username = None if self.core.config["proxy"]["username"] and self.core.config["proxy"]["username"].lower() != "none": @@ -103,4 +107,7 @@ class RequestFactory(): # needs pyreq in global namespace def getURL(*args, **kwargs): - return pyreq.getURL(*args, **kwargs)
\ No newline at end of file + return pyreq.getURL(*args, **kwargs) + +def getRequest(*args, **kwargs): + return pyreq.getHTTPRequest()
\ No newline at end of file |