fix: merge cookies provided by user with session cookies#1201
Conversation
This way we don't need to care about merging with `requestAsBrowserOptions`, as those will be guaranteed to be empty, and it also gives us the final `requestAsBrowserOptions` in the pre-nav hooks (e.g. with the session cookie).
|
@B4nan One quick comment (not sure how much it matters): I guess altering So far we've been doing it on |
|
Thanks for the input, this would indeed be quite a breaking change, I will try to implement support for both. Should be enough to diff the cookie from |
szmarczak
left a comment
There was a problem hiding this comment.
lgtm except that cookie names are case sensitive
Instead of merging cookies with similar names (where only casing differs), we now follow the spec and merge them as separate cookies, but warn (via `log.deprecated()` to have only a single warning printed for each error) when we found such cookies.
Session cookies are no longer saved on the
Requestobject, but passing viarequestAsBrowserOptionsinstead. The cookie value gets calculated based on the session cookie andRequestobject - cookies are merged.preNavigationHooksare now fired after this merging happens, so withrequestAsBrowserOptionsfilled with the cookie header.If two cookies with similar name (where only casing differs), we print a warning, but merge them as two distict cookies.
The
request.headers.cookiesis still possible to override via pre-nav hooks, its value difference will be merged back to therequestAsBrowserOptionsafter pre-nav hooks are executed. This allows to work with bothrequest.headersandrequestAsBrowserOptions.headersinside the pre-nav hooks.Closes #1197