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 af929b2 commit ec6802b
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,14 @@ 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.')

# basic auth info
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
Expand All @@ -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):
Expand Down

0 comments on commit ec6802b

Please sign in to comment.