-
-
Notifications
You must be signed in to change notification settings - Fork 6
Description
The library at the moment does not fully support writing or reading multiple set-cookie responses set in some warc files. I am partially able to workaround the issue when writing, but blocked by the current implementation of the reader.
Writing
By setting keepHeadersCase: false it forces WarcRecord to use the native new Headers(httpHeaders) class as seen on this line.
By passing in a two-dimensional array as documented and seen here:
const headers = [
["Set-Cookie", "PHPSESSID=ppirhpn51gs8a96c323h5kk9mu; path=/; secure; HttpOnly"],
["Set-Cookie", "EngineID=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; domain=.domain.com; secure; HttpOnly"],
];
const myHeaders = new Headers(headers);
I can successfully get Warc Record to write multiple headers:
set-cookie: PHPSESSID=ppirhpn51gs8a96c323h5kk9mu; path=/; secure; HttpOnly
set-cookie: EngineID=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; domain=.domain.com; secure; HttpOnly
Reading
Because StatusAndHeaders reads the buffer line by line and uses .set, it doesn't support multiple set-cookie without creating a comma separated list as seen here.
This is how deno solved a similar issue. I also found this issue at warcio that suggests they support multiple set-cookie headers.
Perhaps we should buffer to array of key, values like warcio before passing it to the class and "it should work"?
I can do some work on this, but wanted to confirm the direction.