summaryrefslogtreecommitdiffstats
path: root/pyload/network/HTTPRequest.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-20 02:21:11 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-20 02:21:11 +0100
commit9cef773c96f48f31d0c021578ab9bc47e9b3acdc (patch)
tree8b701dea430a55ef17d818436d2f973fb3a1b6a1 /pyload/network/HTTPRequest.py
parentConvert tabs to 4-whitespaces (diff)
downloadpyload-9cef773c96f48f31d0c021578ab9bc47e9b3acdc.tar.xz
Use utils encode/decode
Diffstat (limited to 'pyload/network/HTTPRequest.py')
-rw-r--r--pyload/network/HTTPRequest.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/pyload/network/HTTPRequest.py b/pyload/network/HTTPRequest.py
index c1727c0c5..25f5732b5 100644
--- a/pyload/network/HTTPRequest.py
+++ b/pyload/network/HTTPRequest.py
@@ -26,13 +26,15 @@ from cStringIO import StringIO
from pyload.plugins.Plugin import Abort, Fail
+from pyload.utils import encode
+
+
def myquote(url):
- return quote(url.encode('utf_8') if isinstance(url, unicode) else url, safe="%/:=&?~#+!$,;'@()*[]")
+ return quote(encode(url), safe="%/:=&?~#+!$,;'@()*[]")
def myurlencode(data):
data = dict(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()))
+ return urlencode(dict(encode(x), encode(y) for x, y in data.iteritems()))
bad_headers = range(400, 404) + range(405, 418) + range(500, 506)
@@ -167,7 +169,7 @@ class HTTPRequest:
self.c.setopt(pycurl.POSTFIELDS, post)
else:
- post = [(x, y.encode('utf8') if type(y) == unicode else y) for x, y in post.iteritems()]
+ post = [(x, encode(y) for x, y in post.iteritems()]
self.c.setopt(pycurl.HTTPPOST, post)
else:
self.c.setopt(pycurl.POST, 0)