mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Implemented idna (fixes #76).
This commit is contained in:
+5
-1
@@ -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)
|
||||
|
||||
@@ -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__':
|
||||
|
||||
Reference in New Issue
Block a user