Skip to content

v2.6.0 — opt-in session request defaults

Latest

Choose a tag to compare

@lxjmaster lxjmaster released this 23 Oct 10:43
· 25 commits to master since this release

Opt-in session request defaults

Version 2.6.0 adds Session.request_defaults and
AsyncSession.request_defaults for reusable headers and string query pairs.

  • Defaults are disabled initially. Assign a headers/params configuration to
    opt in; assign None or {} to clear it. No constructor changes are required.
  • Configuration is validated and copied atomically; the getter returns a
    detached snapshot. Header names merge case-insensitively, and repeated query
    pairs retain order. Explicit request values override configured values.
  • Empty supported inputs and raw queries retain their native bypass behavior.
    Defaults merge only before initial preparation, not again on hooks, retries,
    redirects or sends of an already prepared request.
  • Authorization, proxy authorization, Cookies, Host and body-framing headers
    remain in their existing APIs and cannot be configured as defaults.
  • Documentation, executable local examples, public typing and 138 focused
    unit/peer cases cover both clients, prepared snapshots and policy boundaries.

Python >=3.7 remains supported. Unconfigured sessions keep their existing
behavior; legacy Session observation properties do not become request defaults.
TLS/H2 engines, browser-profile support and existing timeout/proxy contracts
are unchanged. This release does not claim full Requests or browser parity.

See the configuration guide
and changelog.