| 26 | |
| 27 | |
| 28 | async def default_app(scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None: |
| 29 | scheme = scope["scheme"] # type: ignore |
| 30 | if (client := scope["client"]) is None: # type: ignore |
| 31 | client_addr = "NONE" # pragma: no cover |
| 32 | else: |
| 33 | host, port = client |
| 34 | with contextlib.suppress(ValueError): |
| 35 | if ipaddress.ip_address(host).version == 6: |
| 36 | host = f"[{host}]" |
| 37 | client_addr = f"{host}:{port}" |
| 38 | |
| 39 | response = Response(f"{scheme}://{client_addr}", media_type="text/plain") |
| 40 | await response(scope, receive, send) |
| 41 | |
| 42 | |
| 43 | def make_httpx_client( |