Skip to content

0.9.0

Latest

Choose a tag to compare

@github-actions github-actions released this 11 Nov 19:01
· 1 commit to main since this release

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