[whatwg/fetch] Support 1D list as Header `init` (#1274)

While developing [undici-fetch](https://github.com/ethan-arrowood/undici-fetch) and subsequently adding a [fetch-based Headers class](https://github.com/nodejs/node/pull/38986/) to Node.js, we discovered that a 1D list of header entries is very efficient.

The implementation developed optimizes across multiple use cases (insert, iteration, and look up) so that any use of the instance is still efficient. 

Based on this [comment thread](https://github.com/nodejs/node/pull/38986/#discussion_r675170750) in the Node.js PR, I anticipate this kind of change may not land, but I think it would be valuable to discuss anyways.

The proposed change could be as simple as just allowing 1D array as an `init` argument and only adding some extra details to cast it to the existing, 2D `headers list` backing data structure for the Header api. A more complex (and assumingely unlikely) change would be to update the spec to utilize the 1D based implementation proposed to the Node API. 


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/1274

Received on Tuesday, 27 July 2021 00:30:20 UTC