Repository navigation
Requests now expose client_host, the client's address as the framework reports
it, or None when the framework doesn't know it:
request = AsyncHTTPRequest.from_fastapi(fastapi_request)
request.client_host # "203.0.113.7"Each adapter reads what its framework already provides: request.client.host
in Starlette and Litestar, REMOTE_ADDR in Django, remote_addr in Flask and
Quart, remote in aiohttp, client_ip in Sanic and the API Gateway source IP
in Chalice. Cross Web doesn't read X-Forwarded-For itself, so behind a proxy
this is the proxy's address unless the server is set up to trust its forwarded
headers.
Custom adapters don't have to implement it: client_host returns None unless
an adapter overrides it. The testing adapters take a client_host argument.
This release was contributed by @patrick91 in #23