]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Use a base_url in app dispatcher examples (#799)
authorFlorimond Manca <florimond.manca@gmail.com>
Mon, 3 Feb 2020 12:05:56 +0000 (13:05 +0100)
committerGitHub <noreply@github.com>
Mon, 3 Feb 2020 12:05:56 +0000 (13:05 +0100)
docs/advanced.md
docs/async.md

index 809d84383cfef7307046171e7b9f5a838aff8eff..2dee94ae19cecf8098e3e2f58914acc2bc4f17d1 100644 (file)
@@ -99,8 +99,8 @@ app = Flask(__name__)
 def hello():
     return "Hello World!"
 
-with httpx.Client(app=app) as client:
-    r = client.get('http://example/')
+with httpx.Client(app=app, base_url="http://testserver") as client:
+    r = client.get("/")
     assert r.status_code == 200
     assert r.text == "Hello World!"
 ```
@@ -116,7 +116,7 @@ For example:
 ```python
 # Instantiate a client that makes WSGI requests with a client IP of "1.2.3.4".
 dispatch = httpx.WSGIDispatch(app=app, remote_addr="1.2.3.4")
-with httpx.Client(dispatch=dispatch) as client:
+with httpx.Client(dispatch=dispatch, base_url="http://testserver") as client:
     ...
 ```
 
index 3fd5647aa89eeb118fca427844ee4ae791faa252..81885eef29b17e8a7dd90b37bf4c832e5f20aee2 100644 (file)
@@ -168,8 +168,8 @@ We can make requests directly against the application, like so:
 
 ```python
 >>> import httpx
->>> async with httpx.AsyncClient(app=app) as client:
-...     r = await client.get('http://example/')
+>>> async with httpx.AsyncClient(app=app, base_url="http://testserver") as client:
+...     r = await client.get("/")
 ...     assert r.status_code == 200
 ...     assert r.text == "Hello World!"
 ```
@@ -186,7 +186,7 @@ For example:
 # Instantiate a client that makes ASGI requests with a client IP of "1.2.3.4",
 # on port 123.
 dispatch = httpx.ASGIDispatch(app=app, client=("1.2.3.4", 123))
-async with httpx.AsyncClient(dispatch=dispatch) as client:
+async with httpx.AsyncClient(dispatch=dispatch, base_url="http://testserver") as client:
     ...
 ```