Skip to content

Commit

Permalink
Client can not handle hostnames with 63 bytes when a port is given in…
Browse files Browse the repository at this point in the history
… the url aio-libs#1044

I handled by reconstructing url string.
And I used function make_netlog in client_reqrep.py
  • Loading branch information
Taekyoon committed Aug 15, 2016
1 parent a52c4ea commit f3738f2
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,13 @@ def update_host(self, url):

# check domain idna encoding
try:
netloc = netloc.encode('idna').decode('utf-8')
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)
except UnicodeError:
raise ValueError('URL has an invalid label.')

Expand All @@ -149,6 +154,19 @@ 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):
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):
"""Convert request version to two elements tuple.
Expand Down

0 comments on commit f3738f2

Please sign in to comment.