From 22b346dc7ad12178d247ffbe113b0c8585f72b06 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 9 Nov 2014 02:45:39 +0100 Subject: Cookie support for getURL method --- module/network/RequestFactory.py | 15 +++++++++++++-- 1 file 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): -- cgit v1.2.3