summaryrefslogtreecommitdiffstats
path: root/module/network
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-04 17:19:41 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-04 17:19:41 +0100
commitacd4dceb711e9148ede208bb67dc37bfaafd612b (patch)
tree8b36d3621da994285331b75061c5efefb4d60be1 /module/network
parentoops (diff)
downloadpyload-acd4dceb711e9148ede208bb67dc37bfaafd612b.tar.xz
improved captcha manager
Diffstat (limited to 'module/network')
-rw-r--r--module/network/HTTPRequest.py16
-rw-r--r--module/network/RequestFactory.py8
2 files changed, 14 insertions, 10 deletions
diff --git a/module/network/HTTPRequest.py b/module/network/HTTPRequest.py
index 13e76d5a2..bcd2c696c 100644
--- a/module/network/HTTPRequest.py
+++ b/module/network/HTTPRequest.py
@@ -111,7 +111,7 @@ class HTTPRequest():
def clearCookies(self):
self.c.setopt(pycurl.COOKIELIST, "")
- def setRequestContext(self, url, get, post, referer, cookies):
+ def setRequestContext(self, url, get, post, referer, cookies, multipart=False):
""" sets everything needed for the request """
url = myquote(str(url))
@@ -124,9 +124,13 @@ class HTTPRequest():
self.c.lastUrl = url
if post:
- post = urlencode(post)
- self.c.setopt(pycurl.POSTFIELDS, post)
-
+ if not multipart:
+ post = urlencode(post)
+ self.c.setopt(pycurl.POSTFIELDS, post)
+ else:
+ post = [(x, str(quote(y)) if type(y) in (str, unicode) else y ) for x,y in post.iteritems()]
+ self.c.setopt(pycurl.HTTPPOST, post)
+
if referer and self.lastURL:
self.c.setopt(pycurl.REFERER, self.lastURL)
@@ -136,10 +140,10 @@ class HTTPRequest():
self.getCookies()
- def load(self, url, get={}, post={}, referer=True, cookies=True, just_header=False):
+ def load(self, url, get={}, post={}, referer=True, cookies=True, just_header=False, multipart=False):
""" load and returns a given page """
- self.setRequestContext(url, get, post, referer, cookies)
+ self.setRequestContext(url, get, post, referer, cookies, multipart)
self.header = ""
diff --git a/module/network/RequestFactory.py b/module/network/RequestFactory.py
index ec9ce4350..8340d06f7 100644
--- a/module/network/RequestFactory.py
+++ b/module/network/RequestFactory.py
@@ -49,9 +49,9 @@ class RequestFactory():
self.lock.release()
return req
- def getURL(self, url, get={}, post={}):
+ def getURL(self, url, get={}, post={}, multipart=False):
h = HTTPRequest(None, self.iface(), self.getProxies())
- rep = h.load(url, get, post)
+ rep = h.load(url, get, post, multipart=multipart)
h.close()
return rep
@@ -97,5 +97,5 @@ class RequestFactory():
self.bucket.setRate(self.core.config["download"]["max_speed"] * 1024)
# needs pyreq in global namespace
-def getURL(url, get={}, post={}):
- return pyreq.getURL(url, get, post) \ No newline at end of file
+def getURL(*args, **kwargs):
+ return pyreq.getURL(*args, **kwargs) \ No newline at end of file