getRequestHostname() has similar problems, which this addresses:
def new_getRequestHostname(self):
host = self.getHeader(b'host')
if host:
if host.startswith(b'['):
if host.find(b']') < host.rfind(b':'): return host[:host.rfind(b':')] else: return host
host = self.getHost().host
try:
ip = IPAddress(host.decode("idna"))
except AddrFormatError:
# If we could not convert the hostname to an IPAddress, assume that
# it is a hostname.
return networkString(host)
if ip.version == 4:
return networkString(host)
else:
return networkString(b'[' + host + b']')
getRequestHostn ame() has similar problems, which this addresses:
def new_getRequestH ostname( self): b'host' ) (b'['):
return host[:host. rfind(b' :')]
else:
return host host.decode( "idna") )
host = self.getHeader(
if host:
if host.startswith
if host.find(b']') < host.rfind(b':'):
host = self.getHost().host
try:
ip = IPAddress(
except AddrFormatError:
# If we could not convert the hostname to an IPAddress, assume that
# it is a hostname.
return networkString(host)
if ip.version == 4:
return networkString(host)
else:
return networkString(b'[' + host + b']')