summaryrefslogtreecommitdiffstats
path: root/module/network/HTTPRequest.py
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-12-08 02:04:48 +0100
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-12-08 02:04:48 +0100
commit82aceb93be33157a637905cc807b9b7f7fe15d31 (patch)
tree3296612367ab93848dc146071dc2d38b98ef26cb /module/network/HTTPRequest.py
parentfix webinterface downloads list on synology (diff)
downloadpyload-82aceb93be33157a637905cc807b9b7f7fe15d31.tar.xz
httprequest: encode('utf_8') for unicode post
Diffstat (limited to 'module/network/HTTPRequest.py')
-rw-r--r--module/network/HTTPRequest.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/module/network/HTTPRequest.py b/module/network/HTTPRequest.py
index e58fd114e..40f18f2a5 100644
--- a/module/network/HTTPRequest.py
+++ b/module/network/HTTPRequest.py
@@ -28,7 +28,11 @@ from cStringIO import StringIO
from module.plugins.Plugin import Abort
def myquote(url):
- return quote(url, safe="%/:=&?~#+!$,;'@()*[]")
+ return quote(url.encode('utf_8') if isinstance(url, unicode) else url, safe="%/:=&?~#+!$,;'@()*[]")
+
+def myurlencode(data):
+ return urlencode(dict((x.encode('utf_8') if isinstance(x, unicode) else x, \
+ y.encode('utf_8') if isinstance(y, unicode) else y ) for x, y in data.iteritems()))
bad_headers = range(400, 404) + range(405, 418) + range(500, 506)
@@ -141,7 +145,7 @@ class HTTPRequest():
def setRequestContext(self, url, get, post, referer, cookies, multipart=False):
""" sets everything needed for the request """
- url = myquote(str(url))
+ url = myquote(url)
if get:
get = urlencode(get)
@@ -158,7 +162,7 @@ class HTTPRequest():
elif type(post) == str:
pass
else:
- post = urlencode(post)
+ post = myurlencode(post)
self.c.setopt(pycurl.POSTFIELDS, post)
else: