Add the client address to the request header

This commit is contained in:
Paul Jongsma 2016-11-10 12:53:00 +01:00
parent 5efe51b661
commit be5588d5d8

View File

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