-
Couldn't load subscription status.
- Fork 280
enable curl cookie engine #940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I'm not sure if there is a link between |
|
How to test cookie handling on redirection? 'use scrict'
import puppeteer from 'puppeteer-core';
const browser = await puppeteer.connect({
browserWSEndpoint: 'ws://127.0.0.1:9222',
});
const context = await browser.createBrowserContext();
const page = await context.newPage();
await page.goto("https://httpbin.io/cookies/set?cookie_key=cookie_value", {waitUntil: 'load'});
// received cookies
console.log(await context.cookies());
await page.close();
await context.close();
await browser.disconnect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like it supports the samesite attribute. I tested it out and looked at the source code, couldn't find anything.
The 2nd's field, the domain boolean, is used to indicate whether or not subdomains should be included. In the original, we capture that via a leading dot on the domain (as per the specs). You can ignore it, because CURL also puts the leading dot in the first field. In other words, I believe that this is currently true with the libcurl cookies:
var domain = curl_cookie[0];
var subdomain = curl_cookie[1];
if (subdomain == "true") {
assert(domain[0] == '.');
} else {
assert(domain[0] != '.');
}
Anyways, unless I'm missing something, I feel that the choice is using libcurl's cookie engine, or supporting the samesite attribute. Seems like a simple choice to use libcurl, except for this issue.
Pretty sure we can support redirect cookies with the original code, by placing the existing "Set-Cookie" block inside the existing redirect drain. Might need to grab the URL also:
if (transfer._redirecting) {
{
// add this
const SET_COOKIE_LEN = "set-cookie:".len;
if (header.len > SET_COOKIE_LEN) {
// ...
}
}
return buf_len;
}
I'm not that sure: we will add the cookies returned by the server in our JAR, that's correct, but since Curl handles the redirection itself, it will not inject them on the redirected request, except if we enable the cookie engine. |
|
But maybe we can use both:
|
54543db to
3db5af7
Compare
|
PR updated this way:
It seems to work correctly except one case: if you set manually a cookie ( |
ok, I already have the case with Google search 🤦 |
0dde140 to
7c02554
Compare
Enabling Curl cookie engine brings advantage: * handle cookies during a redirection: when a srv redirects including cookies, curl sends back the cookies correctly during the next request
7c02554 to
7d0e4b6
Compare
Enabling Curl cookie engine brings advantages:
benefit curl's cookie parsing: we now use curl's lib to parse cookies instead of parsing them from headers manuallystill use our own parsing