diff --git a/docs/requests.md b/docs/requests.md index f8d19bb9b..9140bb964 100644 --- a/docs/requests.md +++ b/docs/requests.md @@ -60,8 +60,7 @@ For example: `request.path_params['username']` #### Client Address -The client's remote address is exposed as a named two-tuple `request.client`. -Either item in the tuple may be `None`. +The client's remote address is exposed as a named two-tuple `request.client` (or `None`). The hostname or IP address: `request.client.host` diff --git a/starlette/requests.py b/starlette/requests.py index b27e8e1e2..a2fdfd81e 100644 --- a/starlette/requests.py +++ b/starlette/requests.py @@ -145,7 +145,7 @@ def cookies(self) -> dict[str, str]: @property def client(self) -> Address | None: - # client is a 2 item tuple of (host, port), None or missing + # client is a 2 item tuple of (host, port), None if missing host_port = self.scope.get("client") if host_port is not None: return Address(*host_port)