Skip to content

Support 1D list as Header init #1274

@Ethan-Arrowood

Description

@Ethan-Arrowood

While developing undici-fetch and subsequently adding a fetch-based Headers class 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 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions