From aa0f78b740b6098f29594242b6b923113d0659b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Je=CC=81re=CC=81my=20Bethmont?= Date: Tue, 9 Aug 2011 15:14:08 +0200 Subject: [PATCH] Better support of utf-8 paths. --- requests/models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/requests/models.py b/requests/models.py index 619d099..5110029 100644 --- a/requests/models.py +++ b/requests/models.py @@ -247,10 +247,12 @@ class Request(object): """Build the actual URL to use""" # Support for unicode domain names and paths. - parsed_url = list(urlparse(self.url)) - parsed_url[1] = parsed_url[1].encode('idna') - parsed_url[2] = urllib.quote(urllib.unquote(parsed_url[2])) - self.url = urlunparse(parsed_url) + scheme, netloc, path, params, query, fragment = urlparse(self.url) + netloc = netloc.encode('idna') + if isinstance(path, unicode): + path = path.encode('utf-8') + path = urllib.quote(urllib.unquote(path)) + self.url = str(urlunparse([ scheme, netloc, path, params, query, fragment ])) if self._enc_params: if urlparse(self.url).query: -- 2.34.1