summaryrefslogtreecommitdiffstats
path: root/module/network/RequestFactory.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/network/RequestFactory.py')
-rw-r--r--module/network/RequestFactory.py45
1 files changed, 20 insertions, 25 deletions
diff --git a/module/network/RequestFactory.py b/module/network/RequestFactory.py
index 5b1528281..579eafea7 100644
--- a/module/network/RequestFactory.py
+++ b/module/network/RequestFactory.py
@@ -1,32 +1,16 @@
# -*- coding: utf-8 -*-
-
-"""
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>.
-
- @author: mkaay, RaNaN
-"""
+# @author: RaNaN, mkaay
from threading import Lock
-from Browser import Browser
-from Bucket import Bucket
-from HTTPRequest import HTTPRequest
-from CookieJar import CookieJar
+from pyload.network.Browser import Browser
+from pyload.network.Bucket import Bucket
+from pyload.network.HTTPRequest import HTTPRequest
+from pyload.network.CookieJar import CookieJar
-from XDCCRequest import XDCCRequest
+from pyload.network.XDCCRequest import XDCCRequest
-class RequestFactory():
+class RequestFactory(object):
def __init__(self, core):
self.lock = Lock()
self.core = core
@@ -62,12 +46,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):