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
Commit 96ecd7d
Browse filesBrowse the repository at this point in the historyBrowse files
feat(http-clients)!: Add a cookies argument to send_request (#2352)
### Description
`HttpClient.send_request` and `context.send_request` take a new
`cookies` argument, the cookies to send and store instead of the session
cookies for a single call. To send no session cookies, pass
`cookies=SessionCookies()`. In `PlaywrightCrawler`, they're sent instead
of the browser context cookies, and the response cookies still reach the
session through the browser context.
### Issues
- Part of: #2307
- Follow-up: #2385
*✍️ Drafted by Claude Code*
---------
Co-authored-by: Vlada Dusek <v.dusek96@gmail.com>
Copy file name to clipboardExpand all lines: docs/06_upgrading/upgrading_to_v2.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -387,13 +387,15 @@ The `headers` argument of a client still applies to every request. Its `Authoriz
387
387
388
388
A `Cookie` header passed with a request or set on the client is merged with the session cookies while the redirect chain stays on its origin. A cookie in the header wins over a session cookie of the same name and isn't stored in the session. In v1, `ImpitHttpClient`, `HttpxHttpClient` and `context.send_request` of `PlaywrightCrawler` sent the header instead of the session cookies, so an empty `Cookie` header kept them out. `CurlImpersonateHttpClient` sent the session cookies in a second `Cookie` header.
389
389
390
+
`send_request` and `context.send_request` take a new `cookies` argument, the cookies to send and store instead of the session cookies for a single call. To send no session cookies, pass `cookies=SessionCookies()`. With `PlaywrightCrawler`, the response cookies still reach the session through the browser context.
391
+
390
392
Without a session, or with `persist_cookies_per_session=False`, the cookies a server sets during a redirect chain are sent with the following requests of that chain. In v1, `ImpitHttpClient` and `HttpxHttpClient` didn't send them.
391
393
392
394
### Some client arguments are ignored
393
395
394
396
The following keyword arguments of the underlying libraries are now ignored with a warning:
395
397
396
-
-`cookies` of every client and `cookie_jar` of `ImpitHttpClient`, since cookies are kept in sessions.
398
+
-`cookies` of every client and `cookie_jar` of `ImpitHttpClient`, since cookies are kept in sessions. To send other cookies with a single call, pass `cookies` to `send_request`.
397
399
-`auth` and `params` of `HttpxHttpClient` and `CurlImpersonateHttpClient`, which would reach every request of a redirect chain. Pass the credentials in the `Authorization` header and the query in the URL instead.
398
400
-`max_redirects` of every client and `allow_redirects` of `CurlImpersonateHttpClient`, since `send_request` follows the redirects.
0 commit comments