question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Strange result with `set-cookie` header of `undici.fetch`

See original GitHub issue

Bug Description

Result of set-cookie, Set-cookie, and sEt-CoOkIe header value should be same, but undici.fetch has different result.

Reproducible By

const { fetch } = require('undici');

const response = await fetch('https://maple.gg');

console.log(response.headers); // has set-cookie
console.log(response.headers.get('set-cookie')); // undefined
console.log(response.headers.get('Set-cookie')); // some cookie key and value
console.log(response.headers.get('sEt-CoOkIe')); // some cookie key and value

Expected Behavior

I think all result of get should be same.

Logs & Screenshots

Environment

Ubuntu 20.04 Node v16.14.2

Additional context

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
KhafraDevcommented, Apr 13, 2022

set-cookie is a forbidden header-name so it should be removed entirely (this is similar behavior with browser)

however getting a non-existent header should return null, not undefined.

edit: fixed both bugs and will make a PR soon.

0reactions
KhafraDevcommented, May 23, 2022

Reverted? Probably not. However I’m willing to make a PR once a decision has been made on how to handle cookies in undici/node.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fetch API with Cookie - Stack Overflow
Programmatically overwriting Cookie header in browser side won't work. In fetch documentation, Note that some names are forbidden. is mentioned ...
Read more >
Fetch API has landed into Node.js - Hacker News
In undici this will succeed but with res.status 0 and no headers, ... If more than one of the same header is set...
Read more >
How to securely call an authenticated API from your front end
Your front end needs to access data from an API which requires an API key. How can you keep it safe and do...
Read more >
Using cookie retrieved with HTTP Retriever node doesn't work ...
WARN HTTP Retriever 3:932 Invalid cookie header: "Set-Cookie: ... You can get them with the HTTP Result Data Extractor: ... V strange.
Read more >
fetch vs beacon - compare differences and reviews? | LibHunt
Many HTTP response headers, like etags, are typically computed by buffering the response, running some compute, then sending headers and the buffered body....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found