Skip to content

Provide a way to access raw headers#1437

@blittle

Description

@blittle

This would solve...

As outlined at WHATWG/fetch there is often the need in a server environment to access cookie headers.

For example editing Cookie headers:

consth=newHeaders;h.append("Set-Cookie","a=1; Expires=Wed, 21 Oct 2015 07:28:00 GMT");h.append("Set-Cookie","b=1; Expires=Wed, 21 Oct 2015 07:28:00 GMT");h.get("Set-Cookie")// a=1; Expires=Wed, 21 Oct 2015 07:28:00 GMT, b=1; Expires=Wed, 21 Oct 2015 07:28:00 GMT

Splitting the combined header value by , will give an invalid result. Instead getAll could be used to retrieve the individual headers.

The implementation should look like...

There are two solutions currently proposed:

  1. Node-fetch provides a non-standard Headers.prototype.raw method that returns entries for each (including duplicate) header.
  2. Re-introduce Headers.prototype.getAll to return multiple header values.

I have also considered...

  1. Not use undici primitives within NodeJS.
  2. Attempt to monkey patch undici

Additional context

  1. Cloudflare implemented .getAll().
  2. Node-fetch .raw() implementation
  3. Tracking at WinterCG

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions