]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Use `localhost` instead of `http://localhost` in `TestClient(client=...)` example...
authorWilliam David Edwards <WEdwards@cyberfusion.nl>
Sun, 16 Feb 2025 10:44:10 +0000 (11:44 +0100)
committerGitHub <noreply@github.com>
Sun, 16 Feb 2025 10:44:10 +0000 (07:44 -0300)
With https://github.com/encode/starlette/pull/2810, it is possible to override the client host (i.e. the remote address; see https://www.starlette.io/requests/#client-address).

The default value for `TestClient` is `testclient`, but an IP address in most circumstances.

The documentation example for overriding the client host uses a full URI, which makes no sense: it's the remote address.

docs/testclient.md

index ab05c429053e4dc5442de713d2d35eea97511ea1..b5e3b5b8478a2a9c3ba400e58e4a0f85d5316a11 100644 (file)
@@ -86,7 +86,7 @@ By default, the TestClient will set the client host to `"testserver"` and the po
 You can change the client address by setting the `client` attribute of the `TestClient` instance:
 
 ```python
-client = TestClient(app, client=('http://localhost', 8000))
+client = TestClient(app, client=('localhost', 8000))
 ```
 
 ### Selecting the Async backend