Implemented idna (fixes #76).

This commit is contained in:
Jérémy Bethmont
2011-06-24 12:21:25 +02:00
parent 39edf7a7fa
commit 868cd3d1cb
2 changed files with 8 additions and 1 deletions
+5 -1
View File
@@ -12,7 +12,7 @@ import socket
import zlib
from urllib2 import HTTPError
from urlparse import urlparse
from urlparse import urlparse, urlunparse
from datetime import datetime
from .config import settings
@@ -238,6 +238,10 @@ class Request(object):
def _build_url(self):
"""Build the actual URL to use"""
parsed_url = list(urlparse(self.url))
parsed_url[1] = parsed_url[1].encode('idna')
self.url = urlunparse(parsed_url)
if self._enc_params:
if urlparse(self.url).query:
return '%s&%s' % (self.url, self._enc_params)
+3
View File
@@ -321,6 +321,9 @@ class RequestsTestSuite(unittest.TestCase):
self.assertEquals(rbody.get('form'), None)
self.assertEquals(rbody.get('data'), 'foobar')
def test_idna(self):
r = requests.get(u'http://➡.ws/httpbin')
self.assertEqual(r.url, HTTPBIN_URL)
if __name__ == '__main__':