Skip to content

Comments

docs: fix two broken examples in transports.md#3774

Open
Aiudadadadf wants to merge 1 commit intoencode:masterfrom
Aiudadadadf:doc/fix-transports-https-redirect-example
Open

docs: fix two broken examples in transports.md#3774
Aiudadadadf wants to merge 1 commit intoencode:masterfrom
Aiudadadadf:doc/fix-transports-https-redirect-example

Conversation

@Aiudadadadf
Copy link

Found two broken examples in docs/advanced/transports.md that would confuse anyone trying to run them.

The first is in the "Custom transports" section. It references httpx.Mounts() as a class, which doesn't exist - the correct way to use mounts is passing a dict to Client(mounts=...). The example also had a missing comma between dict entries, and then passed the result in as transport=transport instead of mounts=mounts. Fixed it to use Client(mounts={...}) inline so there's no ambiguity.

The second is in the "Mounting transports" section. The HTTPSRedirectTransport class had handle_request(self, method, url, headers, stream, extensions) returning a tuple (303, headers, stream, extensions) - that's the old low-level transport API from a previous major version. The current BaseTransport.handle_request takes a single Request object and returns a Response. Rewrote it to match, using request.url.copy_with(scheme="https") and httpx.Response(303, ...) the same way the nearby HTTPSRedirect example already does it correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant