File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,13 +38,14 @@ connecting via a Unix Domain Socket that is only available via this low-level AP
3838Another advanced configuration is supplying a custom httpcore [ Network Backend] ( https://www.encode.io/httpcore/network-backends/ ) .
3939
4040``` pycon
41+ >>> import httpcore
4142>>> import httpx
42- >>> import myk8s
43- >>> # This custom network backend enables remote access to ports inside a Kubernetes Cluster using pod port forwarding.
44- >>> backend = myk8s.NetworkBackend(' cluster.local' )
43+ >>> backend = httpcore.MockBackend([b " HTTP/1.1 200 OK\r\n\r\n Hello, World!" ])
4544>>> transport = httpx.HTTPTransport(network_backend = backend)
4645>>> client = httpx.Client(transport = transport)
47- >>> response = client.get(" http://argocd-server.argocd.svc.cluster.local" )
46+ >>> response = client.get(" http://network-backend" )
47+ >>> reposne.text
48+ 'Hello, World!'
4849```
4950
5051## WSGI Transport
Original file line number Diff line number Diff line change 2525client = httpx.Client(transport=transport)
2626
2727# Using advanced httpcore configuration, with custom network backend.
28- import myk8s
29- backend = myk8s.NetworkBackend('cluster.local' )
28+ import httpcore
29+ backend = backend = httpcore.MockBackend([b"HTTP/1.1 200 OK \r \n \r \n Hello, World!"] )
3030transport = httpx.HTTPTransport(network_backend=backend)
3131client = httpx.Client(transport=transport)
32- response = client.get("http://argocd-server.argocd.svc.cluster.local")
32+ response = client.get("http://network-backend")
33+ content = response.text
3334"""
3435
3536from __future__ import annotations
You can’t perform that action at this time.
0 commit comments