🛡️ Safer defaults for streaming, redirects, and TLS
httpx2 and httpcore2 2.18.0 are a minor release. It adds a default per-line cap to iter_lines() and aiter_lines(), strips Proxy-Authorization across origin redirects, reassembles fragmented WebSocket messages in linear time, tightens the default Linux SSL verification flags, and exports AutoBackend from httpcore2.
pip install --upgrade httpx2==2.18.0- Line streaming caps single-line length by default (#1391).
Response.iter_lines()andResponse.aiter_lines()now limit a single buffered line to 1,048,576 characters by default, raisingDecodingErrorand closing the response stream if exceeded. If you stream responses with longer single lines, passmax_line_length=<limit>ormax_line_length=Noneto disable the cap. Proxy-Authorizationis stripped on cross-origin redirects (#1389).BaseClient._redirect_headers()now drops caller-suppliedProxy-Authorizationheaders whenever a redirect changes origin, including same-host HTTP-to-HTTPS upgrades.- Default Linux SSL contexts match Python 3.13+ verify flags (#1393).
httpcore2.default_ssl_context()now setsssl.VERIFY_X509_PARTIAL_CHAINandssl.VERIFY_X509_STRICTon Linux, matchingssl.create_default_context()on Python 3.13 and newer.
⚡ WebSockets and backends
- Fragmented WebSocket messages reassemble with one join (#1272, #1392). Both
WebSocketSessionandAsyncWebSocketSessionnow collect continuation frames in a list (ignoring empty fragments) and join them once when the final frame arrives, avoiding quadratic copying on multi-frame messages. AutoBackendis exported fromhttpcore2(#1390). You can now importAutoBackenddirectly from the top-levelhttpcore2package.
Full changelog: v2.17.2...v2.18.0