wsgiserver AF_UNIX support broken
One of our developers was trying to prototype UNIX socket support our application. They set the socket_file argument in the depot's configuration, and verified that the client could connect. To get to this point, they also had to CherryPy 3.1.2 with the fix for bug
#942 (the patch for #847 has also been applied).
However, the server is returning this traceback, which looks like a bug in CherryPy:
[11/May/2010:16:40:57] Traceback (most recent call last): File "/home/xxx/hg_ws/pkg-uds/proto/root_i386/usr/lib/python2.6/vendor-packages/pkg/server/depotresponse.py", line 75, in setapp self.request = self.get_request() File "/home/xxx/hg_ws/pkg-uds/proto/root_i386/usr/lib/python2.6/vendor-packages/cherrypy/_cpwsgi.py", line 226, in get_request local = _http.Host('', int(env('SERVER_PORT', 80)), ValueError: invalid literal for int() with base 10: ''
If you look at /cherrypy/wsgiserver/init.py:1683, there's the following code:
if isinstance(self.bind_addr, basestring): # AF_UNIX. This isn't really allowed by WSGI, which doesn't # address unix domain sockets. But it's better than nothing. environ["SERVER_PORT"] = "" else: environ["SERVER_PORT"] = str(self.bind_addr) # optional values # Until we do DNS lookups, omit REMOTE_HOST environ["REMOTE_ADDR"] = addr environ["REMOTE_PORT"] = str(addr)
It appears that if an AF_UNIX socket is used, then environ["SERVER_PORT"] = "". Unfortunately, this triggers a bug in _cpwsgi.py, line 226, since it's invalid to call int(""). My guess is that the code in init should simply be changed not to add "SERVER_PORT" to the dictionary, and then the code on line 226 will just work, but I don't know if that's the right fix.
Guidance here appreciated.
Reported by email@example.com