summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-09 02:45:39 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-09 02:45:39 +0100
commit22b346dc7ad12178d247ffbe113b0c8585f72b06 (patch)
treeb07d8440fee3e983d32b928474cd16301954eb84
parent[Captcha9kw] Fix a couple of typo (diff)
downloadpyload-22b346dc7ad12178d247ffbe113b0c8585f72b06.tar.xz
Cookie support for getURL method
-rw-r--r--module/network/RequestFactory.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/module/network/RequestFactory.py b/module/network/RequestFactory.py
index 5b1528281..750f37dc9 100644
--- a/module/network/RequestFactory.py
+++ b/module/network/RequestFactory.py
@@ -62,12 +62,23 @@ 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:
h.close()
-
+
return rep
def getCookieJar(self, pluginName, account=None):