Skip to content
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

Treat Set-Cookie header as an array. #13

Merged
merged 1 commit into from Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/index.ts
Expand Up @@ -106,9 +106,20 @@ async function getResponse(
return createError("Network Error", config, "ERR_NETWORK", request);
}

const stageOneHeaders: Record<string, string> = {};
const stageOneHeaders: Record<string, string | string[]> = {};
stageOne.headers.forEach((value, key) => {
stageOneHeaders[key] = value;
// The `Set-Cookie` header is treated as an array of strings (even if there's only 1)
if (key === "set-cookie") {
const cookies = stageOneHeaders[key] as string[] | undefined

if (cookies) {
cookies.push(value);
} else {
stageOneHeaders[key] = [value];
}
} else {
stageOneHeaders[key] = value;
}
});
const headers: any = Object.assign({}, stageOneHeaders as unknown);
const response: AxiosResponse = {
Expand Down