Merge pull request #717 from jrocketfingers/fix/ipv6-access-log

Fix "TypeError: not all arguments converted during string formatting"
This commit is contained in:
Raphael Deem 2017-05-14 20:28:07 -07:00 committed by GitHub
commit be93d670a3
2 changed files with 3 additions and 2 deletions

View File

@ -143,7 +143,8 @@ class Request(dict):
@property @property
def ip(self): def ip(self):
if not hasattr(self, '_ip'): if not hasattr(self, '_ip'):
self._ip = self.transport.get_extra_info('peername') self._ip = (self.transport.get_extra_info('peername') or
(None, None))
return self._ip return self._ip
@property @property

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)
}) })