0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix(#4550): setCookie should append cookies (#4558)

This commit is contained in:
木杉 2020-04-01 21:37:11 +08:00 committed by GitHub
parent 6291ac82ee
commit 5ac2c4aa2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -115,7 +115,7 @@ export function setCookie(res: Response, cookie: Cookie): void {
// TODO (zekth) : Add proper parsing of Set-Cookie headers
// Parsing cookie headers to make consistent set-cookie header
// ref: https://tools.ietf.org/html/rfc6265#section-4.1.1
res.headers.set("Set-Cookie", toString(cookie));
res.headers.append("Set-Cookie", toString(cookie));
}
/**

View file

@ -206,5 +206,13 @@ test({
res.headers.get("Set-Cookie"),
"__Host-Kitty=Meow; Secure; Path=/"
);
res.headers = new Headers();
setCookie(res, { name: "cookie-1", value: "value-1", secure: true });
setCookie(res, { name: "cookie-2", value: "value-2", maxAge: 3600 });
assertEquals(
res.headers.get("Set-Cookie"),
"cookie-1=value-1; Secure, cookie-2=value-2; Max-Age=3600"
);
},
});