Skip to main content

Module cookie

Module cookie 

Source
Expand description

cookie 库:按**注册域(eTLD+1)**归并,session / persistent 分离。

  • registrable_domain:用 psl 公共后缀表取注册域(example.co.uk / site.com.cn 正确)。
  • CookieJar:内存态 cookie 库,Set-Cookie 回灌(enabledCookieJar)、请求前合并进 Cookie 头; session cookie(无 Expires/Max-Age)仅内存、重启失效,persistent 可落盘(CookieJar::persistent)。 cf_clearance、headful 登录 cookie、Set-Cookie 三路可汇入同一库。

Structs§

CookieJar
内存态 cookie 库:注册域 -> (name -> CookieVal)

Functions§

merge_cookie_str
合并两段 cookie 串(k=v; k2=v2)按 key 去重(second 同名覆盖 first),按字典序输出。
registrable_domain
由 URL 或裸 host 取**注册域(eTLD+1)**作为 cookie 归并键。 psl 正确处理 example.com / example.co.uk / site.com.cn;IP / 单标签 / 未知后缀回退「末两段」。 大小写归一(host 不区分大小写)。