Merge pull request #147 from webtic/master

Add the client address to the request header
This commit is contained in:
Eli Uriegas 2016-11-10 15:30:04 -06:00 committed by GitHub
commit b51af7f4bf

View File

@ -114,6 +114,10 @@ class HttpProtocol(asyncio.Protocol):
self.headers.append((name.decode(), value.decode('utf-8'))) self.headers.append((name.decode(), value.decode('utf-8')))
def on_headers_complete(self): def on_headers_complete(self):
remote_addr = self.transport.get_extra_info('peername')
if remote_addr:
self.headers.append(('Remote-Addr', '%s:%s' % remote_addr))
self.request = Request( self.request = Request(
url_bytes=self.url, url_bytes=self.url,
headers=dict(self.headers), headers=dict(self.headers),