From bf0521c5a9d9ef732c17ce6a68da55f55eef1bf0 Mon Sep 17 00:00:00 2001 From: julien4215 <120588494+julien4215@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:04:43 +0200 Subject: [PATCH 1/4] Fix doc on client address type --- docs/requests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requests.md b/docs/requests.md index f8d19bb9b..c8865e0b0 100644 --- a/docs/requests.md +++ b/docs/requests.md @@ -61,7 +61,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`. +`request.client` may be `None` but each item in the tuple will not be `None`. The hostname or IP address: `request.client.host` From 65c8ffb41c6d7aec8817cc7c4c07d6623b2c9f86 Mon Sep 17 00:00:00 2001 From: julien4215 <120588494+julien4215@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:24:31 +0200 Subject: [PATCH 2/4] fix comment about client property --- starlette/requests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 8ed49a9912cf56fa7f60952b599bc4566c2c175f Mon Sep 17 00:00:00 2001 From: julien4215 <120588494+julien4215@users.noreply.github.com> Date: Wed, 24 Apr 2024 20:55:29 +0200 Subject: [PATCH 3/4] Simplify wording Co-authored-by: Marcelo Trylesinski --- docs/requests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requests.md b/docs/requests.md index c8865e0b0..a431081ea 100644 --- a/docs/requests.md +++ b/docs/requests.md @@ -60,7 +60,7 @@ For example: `request.path_params['username']` #### Client Address -The client's remote address is exposed as a named two-tuple `request.client`. +The client's remote address is exposed as a named two-tuple `request.client` (or `None`). `request.client` may be `None` but each item in the tuple will not be `None`. The hostname or IP address: `request.client.host` From 2220954b803bc4b0ce0d62fd85021486a2a18544 Mon Sep 17 00:00:00 2001 From: julien4215 <120588494+julien4215@users.noreply.github.com> Date: Wed, 24 Apr 2024 23:00:39 +0200 Subject: [PATCH 4/4] Remove useless line Co-authored-by: Marcelo Trylesinski --- docs/requests.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/requests.md b/docs/requests.md index a431081ea..9140bb964 100644 --- a/docs/requests.md +++ b/docs/requests.md @@ -61,7 +61,6 @@ For example: `request.path_params['username']` #### Client Address The client's remote address is exposed as a named two-tuple `request.client` (or `None`). -`request.client` may be `None` but each item in the tuple will not be `None`. The hostname or IP address: `request.client.host`