CodeVetter · Repo Unpack · Extension points
encode/httpx
Extension is primarily explicit object injection rather than automatic plugin discovery. Transports replace execution, mounts route execution, and Auth generators implement multi-exchange credential behavior. Hooks and extensions add observation and transport-specific metadata without changing the simplified Request/Response model. Internal decoder registries and the CLI option table provide additional edit locations, with public exports checked separately.
- Custom transports subclass BaseTransport.handle_request() or AsyncBaseTransport.handle_async_request(), return Response, and implement close/aclose when they own resources; Client._init_transport() returns an injected transport directly.
- mounts maps URL patterns to transports or None; explicit entries update proxy-derived mounts, sorting uses URLPattern priority, and the first match selects its transport or falls back to the default for None.
- Auth.auth_flow() is a Request/Response generator protocol supporting multiple exchanges; requires_request_body and requires_response_body trigger buffering, and I/O-bearing schemes can override sync_auth_flow()/async_auth_flow().
- Client event_hooks registers lists under request and response, can be changed through the property, and may mutate models. AsyncClient awaits hooks; response hooks needing content must explicitly read or await aread().
- Request/Response extensions are an untyped transport-specific channel; the default transport forwards them, documented request keys include timeout and trace, and response network_stream permits lower-level connection access.
- MockTransport injects a Request-to-Response handler, reads the request body before dispatch, and allows async clients to use either sync or coroutine handlers; sync clients reject an async handler result.
- SUPPORTED_DECODERS maps content-encoding names to ContentDecoder classes and drops unavailable optional codecs; Response selects and combines those decoders. default_encoding separately accepts a callable over buffered bytes for text detection.
- CLI options are defined by Click decorators around main(), while package-level symbols are curated in __all__; test_all_imports_are_exported checks that public imports match the sorted export list.