Merge pull request #1039 from lixxu/master

check request.ip before using it
This commit is contained in:
Raphael Deem 2017-11-28 19:47:34 -08:00 committed by GitHub
commit aa4821864a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -312,13 +312,14 @@ class HttpProtocol(asyncio.Protocol):
else: else:
extra['byte'] = -1 extra['byte'] = -1
extra['host'] = 'UNKNOWN'
if self.request is not None: if self.request is not None:
extra['host'] = '{0}:{1}'.format(self.request.ip[0], if self.request.ip:
self.request.ip[1]) extra['host'] = '{0[0]}:{0[1]}'.format(self.request.ip)
extra['request'] = '{0} {1}'.format(self.request.method, extra['request'] = '{0} {1}'.format(self.request.method,
self.request.url) self.request.url)
else: else:
extra['host'] = 'UNKNOWN'
extra['request'] = 'nil' extra['request'] = 'nil'
access_logger.info('', extra=extra) access_logger.info('', extra=extra)