[Bug 1604608] Re: ipv6 client causes errors in twisted.web
LaMont Jones
lamont.jones at canonical.com
Mon Jul 25 15:44:44 UTC 2016
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']')
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to twisted in Ubuntu.
https://bugs.launchpad.net/bugs/1604608
Title:
ipv6 client causes errors in twisted.web
Status in twisted package in Ubuntu:
New
Bug description:
If the client connecting to the twisted (16.0.0-1, still present in upstream 16.3.0), then twisted dies as follows:
2016-07-18 15:40:21 [HTTPChannel,468,::ffff:127.0.0.1] Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/twisted/web/http.py", line 1657, in lineReceived
self.allContentReceived()
File "/usr/lib/python3/dist-packages/twisted/web/http.py", line 1736, in allContentReceived
req.requestReceived(command, path, version)
File "/usr/lib/python3/dist-packages/maasserver/webapp.py", line 80, in requestReceived
command, path, version)
File "/usr/lib/python3/dist-packages/twisted/web/http.py", line 762, in requestReceived
self.process()
--- <exception caught here> ---
File "/usr/lib/python3/dist-packages/twisted/web/server.py", line 183, in process
self.render(resrc)
File "/usr/lib/python3/dist-packages/twisted/web/server.py", line 234, in render
body = resrc.render(self)
File "/usr/lib/python3/dist-packages/twisted/web/wsgi.py", line 561, in render
self._reactor, self._threadpool, self._application, request)
File "/usr/lib/python3/dist-packages/twisted/web/wsgi.py", line 293, in __init__
'REMOTE_ADDR': _wsgiString(request.getClientIP()),
File "/usr/lib/python3/dist-packages/twisted/web/wsgi.py", line 85, in _wsgiString
return string.decode("iso-8859-1")
builtins.AttributeError: 'NoneType' object has no attribute 'decode'
In the attached patch, the middle block addresses the above immediate
issue, and the other two blocks are my best guess at what the code
_should_ read for completeness.
We'll want to get this SRUed into xenial, once it's fixed in wily, as
it's required for MAAS 2.1 (which runs on "latest LTS release" ==
xenial.)
thanks
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/twisted/+bug/1604608/+subscriptions
More information about the foundations-bugs
mailing list