Commit 82f50339 authored by Denis Bilenko's avatar Denis Bilenko

pywsgi: fix logging when bound on unix socket

Thanks to Chris Meyers (#295), Eugene Pankov (#300).

Added examples: unixsocket_server.py and unixsocket_client.py that help reproduce the issue.
parent aadb5251
import socket
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect("./unixsocket_server.py.sock")
s.send('GET / HTTP/1.0\r\n\r\n')
data = s.recv(1024)
print 'received %s bytes' % len(data)
print data
s.close()
import os
from gevent.pywsgi import WSGIServer
from gevent import socket
def application(environ, start_response):
start_response('200 OK', [])
return []
if __name__ == '__main__':
listener = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sockname = './' + os.path.basename(__file__) + '.sock'
if os.path.exists(sockname):
os.remove(sockname)
listener.bind(sockname)
listener.listen(1)
WSGIServer(listener, application).serve_forever()
......@@ -466,8 +466,9 @@ class WSGIHandler(object):
delta = '%.6f' % (self.time_finish - self.time_start)
else:
delta = '-'
client_address = self.client_address[0] if isinstance(self.client_address, tuple) else self.client_address
return '%s - - [%s] "%s" %s %s %s' % (
self.client_address[0],
client_address or '-',
now,
self.requestline,
(getattr(self, 'status', None) or '000').split()[0],
......
......@@ -6,7 +6,7 @@ import util
cwd = '../examples/'
ignore = ['wsgiserver.py', 'wsgiserver_ssl.py', 'webproxy.py', 'webpy.py']
ignore = ['wsgiserver.py', 'wsgiserver_ssl.py', 'webproxy.py', 'webpy.py', 'unixsocket_server.py', 'unixsocket_client.py']
if sys.platform == 'win32':
ignore += ['geventsendfile.py', 'psycopg2_pool.py']
ignore += [x[14:] for x in glob.glob('test__example_*.py')]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment