summaryrefslogtreecommitdiffstats
path: root/module/network/CookieJar.py
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2010-12-22 20:33:23 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2010-12-22 20:33:23 +0100
commit0fd06af30e6ec943b6ddcfed2e2cf4cd64095309 (patch)
treef82c64a4504412ac848285cbf5a235e4295cb106 /module/network/CookieJar.py
parentfixed getURL (diff)
downloadpyload-0fd06af30e6ec943b6ddcfed2e2cf4cd64095309.tar.xz
cookie handling WIP -.-
Diffstat (limited to 'module/network/CookieJar.py')
-rw-r--r--module/network/CookieJar.py33
1 files changed, 30 insertions, 3 deletions
diff --git a/module/network/CookieJar.py b/module/network/CookieJar.py
index fc6b5e076..372e2001e 100644
--- a/module/network/CookieJar.py
+++ b/module/network/CookieJar.py
@@ -19,7 +19,7 @@
from cookielib import CookieJar as PyCookieJar
from cookielib import Cookie
-
+from time import time
class CookieJar(PyCookieJar):
def __init__(self, pluginName=None, account=None):
@@ -27,7 +27,6 @@ class CookieJar(PyCookieJar):
self.plugin = pluginName
self.account = account
-
def getCookie(self, name):
print "getCookie not implemented!"
return None
@@ -38,4 +37,32 @@ class CookieJar(PyCookieJar):
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) \ No newline at end of file
+ self.set_cookie(c)
+
+ def add_cookie_header(self, request):
+ self._cookies_lock.acquire()
+ try:
+
+ self._policy._now = self._now = int(time())
+
+ cookies = self._cookies_for_request(request)
+
+ attrs = self._cookie_attrs(cookies)
+ print attrs
+ if attrs:
+ if not request.has_header("Cookie"):
+ request.add_header(
+ "Cookie", "; ".join(attrs))
+
+ # if necessary, advertise that we know RFC 2965
+ if (self._policy.rfc2965 and not self._policy.hide_cookie2 and
+ not request.has_header("Cookie2")):
+ for cookie in cookies:
+ if cookie.version != 1:
+ request.add_header("Cookie2", '$Version="1"')
+ break
+
+ finally:
+ self._cookies_lock.release()
+
+ self.clear_expired_cookies()