Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
smilingthax opened this issue Apr 8, 2023 · 1 comment · Fixed by #2052
Closed

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

smilingthax opened this issue Apr 8, 2023 · 1 comment · Fixed by #2052
Labels
bug Something isn't working fetch

Comments

@smilingthax
Copy link

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!
@smilingthax smilingthax changed the title HeaderList.clear() does not clear .cookies HeadersList.clear() does not clear .cookies Apr 8, 2023
@KhafraDev
Copy link
Member

KhafraDev commented Apr 8, 2023

Can you provide a code sample that uses undici.fetch & a node http server?

edit: nvm I misread it

@KhafraDev KhafraDev added bug Something isn't working fetch labels Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fetch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants