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

If Request is passed as the first parameter and no header is passed, the set-cookie header is not cloned. #2445

Closed
tsctx opened this issue Nov 20, 2023 · 0 comments · Fixed by #2446
Labels
bug Something isn't working

Comments

@tsctx
Copy link
Member

tsctx commented Nov 20, 2023

Bug Description

If Request is passed as the first parameter and no header is passed, the set-cookie header is not cloned.

Reproducible By

const request = new Request("https://example.com", { headers: { "set-cookie": "A"  } });
const req = new Request(request);
req.headers.append("set-cookie", "B");
console.log(request.headers.getSetCookie()); //  [ 'A', 'B' ]
console.log(req.headers.getSetCookie()); // [ 'A', 'B' ]
console.log(request.headers.get("set-cookie")); // 'A'
console.log(req.headers.get("set-cookie")); // 'A, B'

Expected Behavior

const request = new Request("https://example.com", { headers: { "set-cookie": "A"  } });
const req = new Request(reqeust);
req.headers.append("set-cookie", "B");
console.log(request.headers.getSetCookie()); //  [ 'A' ]
console.log(req.headers.getSetCookie()); // [ 'A', 'B' ]
console.log(request.headers.get("set-cookie")); // 'A'
console.log(req.headers.get("set-cookie")); // 'A, B'

Logs & Screenshots

> $ node
Welcome to Node.js v21.1.0.
Type ".help" for more information.
> const request = new Request("https://example.com", { headers: { "set-cookie": "A"  } });
undefined
> const req = new Request(request);
undefined
> req.headers.append("set-cookie", "B");
undefined
> console.log(request.headers.getSetCookie());
[ 'A', 'B' ]
undefined
> console.log(req.headers.getSetCookie());
[ 'A', 'B' ]
undefined
> console.log(request.headers.get("set-cookie"))
A
undefined
> console.log(req.headers.get("set-cookie"))
A, B
undefined

Environment

Additional context

@tsctx tsctx added the bug Something isn't working label Nov 20, 2023
@tsctx tsctx mentioned this issue Nov 20, 2023
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant