-
Notifications
You must be signed in to change notification settings - Fork 2.1k
"Add" cookies feature. Support for cookie propagation in case if target page returns 302. #1463
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
Support for caches propagation in case of 302 re-directs on target page.
|
|
Hi @martinsefcik, thanks for review,
Hmm, let me check this on the weekend. Seems as there is no cookie support for cli version at all, possibly can go as a separate PR.
Ok, will split
Yep, I've checked and played with this one a little. In my implementation, one of issues I didn't consider -> recursive redirects. They won't stop, as there is no max redirects count property anymore, just recursive calls. This one will require a fix If decision is made to keep custom implementation and not the lib. Will check both approaches on the weekends. |
|
@martinsefcik, good day! const wrapInCookieAgent = (AgentClass, ...args) => {
const CookieAgentClass = createCookieAgent(AgentClass);
const jar = getCookieJar();
return new CookieAgentClass({ cookies: { jar }} , ...args);
}
constructor(...params: ConstructorParams) {
const { cookies: cookieOptions } = (params.find((opt) => {
return opt != null && typeof opt === 'object' && 'cookies' in opt;
}) ?? {}) as CookieAgentOptions;
super(...(params as Params));It messes with SocksProxyAgent constructor which is used:
If there is no way to handle these challenges in a good way, I can:
What would you suggest to be the best way? |
|
Hey @r-polunin, thanks for taking the time to contribute! |

Related to:
#968
If we have a chain of requests, i.e: request -> 302 re-direct -> 302 re-direct -> page.
Cookies from the first re-direct response are not propagated further.
This happens because of the way how axios works:
axios/axios#3862
Solution:
During the request preparation, if "Save cookies" checkbox is set, maxRedirections for axios instance will be set to 0 and further re-direction requests will be triggered re-cursively in error handler, new interceptors will be storing and enriching cookies.
Cookies UI:
New element allowing manual addition of the cookies is implemented. Table key is changed from domain to domain + path.