reqwest.cookie_store
reqwest.cookie_store
功能
启用或关闭当前请求客户端的 Cookie 存储。启用后,重定向过程中服务端写入的 Set-Cookie 会在后续跳转请求中继续携带。
语法
reqwest(url).cookie_store(enabled)
参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| enabled | Bool | 否 | true | 是否启用 Cookie 存储。 |
返回值
| 类型 | 说明 |
|---|---|
| Reqwest | 返回当前请求构建器克隆。 |
示例
request = reqwest('https://example.com').cookie_store(true) result = type(request) // 输出:Reqwest print result
注意事项
- 启用 Cookie 存储后,重定向过程中收到的 Set-Cookie 只在本次 send() 及其重定向链路中继续携带。
-
cookie_store(true)的请求不会进入共享 HTTP client 池,避免不同请求之间共享 Cookie 状态。