FetchResponse objects for a response with multiple of the same HTTP header ignore all but the last value
catgirlinspace opened this issue · 3 comments
HTTP allows for the same header to be sent multiple times. This is often used for Set-Cookie
and Link
in my experience.
Repro:
% lune
Lune v0.7.8
> print(require("@lune/net").request("https://news.indieweb.org/en").headers)
{
["set-cookie"] = "PHPSESSID=aVeryCoolSessionId; path=/",
["cache-control"] = "no-store, no-cache, must-revalidate",
expires = "Thu, 19 Nov 1981 08:52:00 GMT",
link = "<https://switchboard.p3k.io/>; rel=\"hub\"",
date = "Wed, 18 Oct 2023 04:10:54 GMT",
pragma = "no-cache",
["content-type"] = "text/html; charset=UTF-8",
server = "nginx/1.24.0",
}
When making the same request in a browser, the DevTools show several Link
headers.
Personally, I wouldn't call this an enhancement. It's definitely a bug. Information from the response is being removed when it should not be.
Personally, I wouldn't call this an enhancement. It's definitely a bug. Information from the response is being removed when it should not be.
I agree that we should lift this limitation but it's not really a bug since it was intentional - both headers and query parameters are simple string -> string maps since at the time of implementation it wasn't clear what to do about multi-values, and nobody had a use case for them just yet.
Added support for this in c9ce297