From ec6802b7f3dab7ba919272ad7c879ed0b7adce13 Mon Sep 17 00:00:00 2001 From: Taekyoon Date: Mon, 15 Aug 2016 15:45:52 +0900 Subject: [PATCH] Client can not handle hostnames with 63 bytes when a port is given in the url #1044 I handled by reconstructing url string. And I used function make_netlog in client_reqrep.py --- aiohttp/client_reqrep.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index 095d6e860f4..19c69818376 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -126,10 +126,7 @@ def update_host(self, url): host = host.encode('idna').decode('utf-8') #To show more compact to implement codes, I used 'make_netloc' function. #I think it would be nicer... than implement all contents. - netloc = self.make_netloc(url_parsed.username, - url_parsed.password, - host, - url_parsed.port) + netloc = self.make_netloc(host, url_parsed.port) except UnicodeError: raise ValueError('URL has an invalid label.') @@ -137,7 +134,6 @@ def update_host(self, url): username, password = url_parsed.username, url_parsed.password if username: self.auth = helpers.BasicAuth(username, password or '') - netloc = netloc.split('@', 1)[1] # Record entire netloc for usage in host header self.netloc = netloc @@ -155,16 +151,11 @@ def update_host(self, url): self.host, self.port, self.scheme = host, port, scheme #Already Coded from yarl project.. I just copied it! - def make_netloc(self, user, password, host, port): + #Netlog needs only host and port strings. + def make_netloc(self, host, port): ret = host if port: ret = ret + ':' + str(port) - if password: - if not user: - raise ValueError("Non-empty password requires non-empty user") - user = user + ':' + password - if user: - ret = user + '@' + ret return ret def update_version(self, version):