From 8b859774262b5b1ea4fd096bd6ab9bfdc975f9b1 Mon Sep 17 00:00:00 2001 From: Lim-jooyoung Date: Mon, 23 Nov 2026 21:36:18 +0900 Subject: [PATCH] Docs: fix the 'target' extension examples The top-level httpx.get() and httpx.request() functions do not accept an extensions argument, so both examples raised TypeError. Use a Client, as the other examples on the page do, and send OPTIONS * to match the text describing server-wide OPTIONS * requests. --- docs/advanced/extensions.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/advanced/extensions.md b/docs/advanced/extensions.md index d9208ccdb3..a969259a01 100644 --- a/docs/advanced/extensions.md +++ b/docs/advanced/extensions.md @@ -165,8 +165,9 @@ Using the 'target' extension to send requests without the standard path escaping # # Note that requests must still be valid HTTP requests. # For example including whitespace in the target will raise a `LocalProtocolError`. +client = httpx.Client() extensions = {"target": b"/test^path"} -response = httpx.get("https://www.example.com", extensions=extensions) +response = client.get("https://www.example.com", extensions=extensions) ``` The `target` extension also allows server-wide `OPTIONS *` requests to be constructed... @@ -174,9 +175,10 @@ The `target` extension also allows server-wide `OPTIONS *` requests to be constr ```python # This will send the following request... # -# CONNECT * HTTP/1.1 +# OPTIONS * HTTP/1.1 +client = httpx.Client() extensions = {"target": b"*"} -response = httpx.request("CONNECT", "https://www.example.com", extensions=extensions) +response = client.request("OPTIONS", "https://www.example.com", extensions=extensions) ``` ## Response Extensions