Skip to content

HeadersList.clear() does not clear .cookies #2050

@smilingthax

Description

@smilingthax

Since .getSetCookie() was introduced, HeaderList has an additional .cookies field, which is not updated on .clear():

clear () {
this[kHeadersMap].clear()
this[kHeadersSortedMap] = null
}

This is observable:

const req1 = new undici.Request('http://localhost', {
  headers: {
    'set-cookie': 'a=1'
  }
});
console.log([...req1.headers]);   // --> [ [ 'set-cookie', 'a=1' ] ]
const req2 = new undici.Request(req1, {
  headers: {}
});
console.log([...req2.headers]);    // --> []
console.log(req2.headers.getSetCookie());   // --> [ 'a=1' ]   - unexpected!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfetch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions