diff options
author | mkaay <mkaay@mkaay.de> | 2010-12-22 13:45:30 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2010-12-22 13:45:30 +0100 |
commit | dde6a329fdaa5dca48080770dee82cb51cf12585 (patch) | |
tree | d665099c49a0ef1f5c09a9d2f8b19ba09f531437 /module/RequestFactory.py | |
parent | at least its downloading now (diff) | |
download | pyload-dde6a329fdaa5dca48080770dee82cb51cf12585.tar.xz |
refactoring part 1: deprecation warnings, reduced debug, cookie compatibility
Diffstat (limited to 'module/RequestFactory.py')
-rw-r--r-- | module/RequestFactory.py | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/module/RequestFactory.py b/module/RequestFactory.py index 8bd27a275..5eaa32ed9 100644 --- a/module/RequestFactory.py +++ b/module/RequestFactory.py @@ -23,6 +23,8 @@ from module.network.Browser import Browser from module.network.XdccRequest import XdccRequest from module.network.FtpRequest import FtpRequest from time import time +from cookielib import CookieJar +from cookielib import Cookie class RequestFactory(): def __init__(self, core): @@ -40,7 +42,7 @@ class RequestFactory(): cj = self.getCookieJar(pluginName, account) req.setCookieJar(cj) else: - req.setCookieJar(CookieJar(pluginName)) + req.setCookieJar(PyLoadCookieJar(pluginName)) elif type == "XDCC": req = XdccRequest() @@ -62,12 +64,13 @@ class RequestFactory(): for cj in self.cookiejars: if (cj.plugin, cj.account) == (plugin, account): return cj - cj = CookieJar(plugin, account) + cj = PyLoadCookieJar(plugin, account) self.cookiejars.append(cj) return cj -class CookieJar(): +class PyLoadCookieJar(CookieJar): def __init__(self, plugin, account=None): + CookieJar.__init__(self) self.cookies = {} self.plugin = plugin self.account = account @@ -78,23 +81,14 @@ class CookieJar(): if hasattr(self, "plugin"): del self.plugin - def addCookies(self, clist): - for c in clist: - name = c.split("\t")[5] - self.cookies[name] = c - - def getCookies(self): - return self.cookies.values() - - def parseCookie(self, name): - if self.cookies.has_key(name): - return self.cookies[name].split("\t")[6] - else: - return None - def getCookie(self, name): - return self.parseCookie(name) + print "getCookie not implemented!" + return None - def setCookie(self, domain, name, value, path="/", exp=time()+3600*24*180): - s = ".%s TRUE %s FALSE %s %s %s" % (domain, path, exp, name, value) - self.cookies[name] = s + def setCookie(self, domain, name, value, path="/"): + c = Cookie(version=0, name=name, value=value, port=None, port_specified=False, + domain=domain, domain_specified=False, + domain_initial_dot=(domain.startswith(".")), path=path, path_specified=True, + secure=False, expires=None, discard=True, comment=None, + comment_url=None, rest={'HttpOnly': None}, rfc2109=False) + self.set_cookie(c) |