You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Move redirect and cookie handling into a shared HttpClient base class #2307
HttpClient has three abstract entry points (crawl, send_request, stream in http_clients/_base.py). Each implementation re-implements redirect hops, the per-hop Cookie header, stripping credentials on cross-origin redirects and saving Set-Cookie into the session: ImpitHttpClient._request_with_redirects, the HttpxHttpClient transport adapter, and the curl client. A custom client has to get all of that right on its own.
JS v4 moved cookie and redirect handling into a BaseHttpClient, and a custom client implements a single fetch-like method. This is the concrete shape for #874.
Proposed solution
An abstract per-hop primitive that a client implements. The base class follows redirects, assembles cookies from the session and persists response cookies, once for all clients.
Merge a Cookie header passed by the caller with the session cookies by name, with the caller winning per cookie. Today the caller's header replaces the session cookies entirely, in both impit and httpx. Consider a per-call cookie jar override, as in JS.
Rename persist_cookies_per_session to save_response_cookies, and decide whether it becomes a crawler option, as in JS.
Activity
janbuchar commentedon Oct 15, 2026
Explain how? 😁