Skip to content

Strange result with set-cookie header of undici.fetch #1328

Closed

Description

@cjh980402

Bug Description

Result of set-cookie, Set-cookie, and sEt-CoOkIe header value should be same, but undici.fetch has different result.

Reproducible By

const { fetch } = require('undici');

const response = await fetch('https://maple.gg');

console.log(response.headers); // has set-cookie
console.log(response.headers.get('set-cookie')); // undefined
console.log(response.headers.get('Set-cookie')); // some cookie key and value
console.log(response.headers.get('sEt-CoOkIe')); // some cookie key and value

Expected Behavior

I think all result of get should be same.

Logs & Screenshots

Environment

Ubuntu 20.04
Node v16.14.2

Additional context

Activity

  1. added
    bug
    on Apr 9, 2022
  2. RafaelGSS commented on Apr 9, 2022

    @RafaelGSS
    Member

    @cjh980402 which undici version are you using?

  3. cjh980402 commented on Apr 9, 2022

    @cjh980402
    ContributorAuthor

    @RafaelGSS I use undici 5.0.0.

  4. KhafraDev commented on Apr 13, 2022

    @KhafraDev
    Member

    set-cookie is a forbidden header-name so it should be removed entirely (this is similar behavior with browser)

    however getting a non-existent header should return null, not undefined.

    edit: fixed both bugs and will make a PR soon.

  5. aeharding commented on May 23, 2022

    @aeharding

    set-cookie is a forbidden header-name so it should be removed entirely (this is similar behavior with browser)

    @KhafraDev if this is true, it seems like a case of a spec being written in the context of the browser, and not node.

    Is there any chance of this being reverted? This change makes the fetch API not usable for me.

  6. KhafraDev commented on May 23, 2022

    @KhafraDev
    Member

    Reverted? Probably not. However I'm willing to make a PR once a decision has been made on how to handle cookies in undici/node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions