Fix "TypeError: not all arguments converted during string formatting"

socket.getpeername() returns AF_INET6 address family four-tuple, with
flowid and scopeid.

In server's write_response, an exception is raised when an IPv6 client
connects due to four-tuple elements having two unused elements (flowid
and scopeid).

This makes sure that only the first two (host and port) are used in log
string formatting.
This commit is contained in:
Johnny 2017-05-13 17:35:04 +02:00
parent fa1b7de52a
commit 4c7675939a

View File

@ -201,7 +201,7 @@ class HttpProtocol(asyncio.Protocol):
netlog.info('', extra={ netlog.info('', extra={
'status': response.status, 'status': response.status,
'byte': len(response.body), 'byte': len(response.body),
'host': '%s:%d' % self.request.ip, 'host': '%s:%d' % (self.request.ip[0], self.request.ip[1]),
'request': '%s %s' % (self.request.method, 'request': '%s %s' % (self.request.method,
self.request.url) self.request.url)
}) })