# Data flow — encode/httpx

> Canonical page: https://codevetter.com/unpack/httpx/data-flow

# Data flow — encode/httpx

Scanned commit b5addb64f0161ff6bfe94c124ef76f6a1fba5254 (2026-02-23). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Request construction turns caller inputs into normalized URL, header, cookie, extension, and stream objects. Authentication and redirect loops can produce additional exchanges before the final response reaches the caller. Transports preserve raw protocol data and delegate network execution, while response models decode and optionally buffer bodies. State persists through the client cookie jar and connection pools; CLI downloads explicitly write decoded content.
- build_request() merges URL, headers, cookies, and query parameters, inserts a timeout extension unless already supplied, then constructs Request with the merged values and body inputs. — [httpx/_client.py#L366-L389](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_client.py#L366-L389)
- URL construction validates component types and invokes urlparse(); normalization lowercases scheme, encodes hosts, normalizes ports and paths, and preserves the distinction between absent and empty query strings. — [httpx/_urls.py#L77-L124](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_urls.py#L77-L124) [httpx/_urlparse.py#L293-L345](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_urlparse.py#L293-L345)
- Request uppercases the method, copies extensions, applies cookie headers, and invokes encode_request(); body selection prefers explicit content, then files, nonempty form data, and JSON, with a deprecated raw-data compatibility branch. — [httpx/_models.py#L398-L423](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_models.py#L398-L423) [httpx/_content.py#L186-L218](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_content.py#L186-L218)
- Body encoders return headers plus a byte stream: known lengths use Content-Length, unknown iterable lengths use chunked transfer, and multipart length becomes unknown when any file length cannot be determined. — [httpx/_content.py#L107-L131](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_content.py#L107-L131) [httpx/_multipart.py#L265-L300](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_multipart.py#L265-L300) [httpx/_models.py#L441-L460](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_models.py#L441-L460)
- send() resolves timeout/auth policy; each exchange runs request hooks, dispatches through the URL-selected transport, runs response hooks, and either returns, follows a redirect, or exposes next_request. — [httpx/_client.py#L899-L925](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_client.py#L899-L925) [httpx/_client.py#L964-L999](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_client.py#L964-L999) [httpx/_client.py#L1001-L1014](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_client.py#L1001-L1014)
- HTTPTransport converts raw scheme, host, port, request target, headers, stream, and extensions into httpcore.Request; pool output becomes Response with wrapped response stream and preserved extensions. — [httpx/_transports/default.py#L237-L259](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_transports/default.py#L237-L259)
- The client attaches the originating request, binds elapsed-time tracking to stream closure, extracts Set-Cookie into its jar, and supplies default text encoding; subsequent requests obtain Cookie headers through CookieJar adapters. — [httpx/_client.py#L139-L159](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_client.py#L139-L159) [httpx/_client.py#L1016-L1024](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_client.py#L1016-L1024) [httpx/_models.py#L1101-L1115](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_models.py#L1101-L1115) [httpx/_models.py#L1243-L1277](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_models.py#L1243-L1277)
- iter_raw() counts received bytes; iter_bytes() applies content decoding and chunking; read() joins decoded chunks into cached content. CLI download_response() writes iter_bytes() chunks while reporting raw-byte progress. — [httpx/_models.py#L876-L905](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_models.py#L876-L905) [httpx/_models.py#L935-L959](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_models.py#L935-L959) [httpx/_main.py#L251-L270](https://github.com/encode/httpx/blob/b5addb64f0161ff6bfe94c124ef76f6a1fba5254/httpx/_main.py#L251-L270)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
