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

fix: clear cache #2519

Merged
merged 8 commits into from
Dec 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 15 additions & 4 deletions lib/fetch/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ class HeadersList {
* @param {string} value
*/
lowerCaseSet (name, value) {
this[kHeadersSortedMap] = null
tsctx marked this conversation as resolved.
Show resolved Hide resolved

if (name === 'set-cookie') {
this.cookies = [value]
}
Expand All @@ -257,7 +259,14 @@ class HeadersList {
* @param {string} name
*/
delete (name) {
tsctx marked this conversation as resolved.
Show resolved Hide resolved
return this.lowerCaseDelete(name.toLowerCase())
this[kHeadersSortedMap] = null
name = name.toLowerCase()

if (name === 'set-cookie') {
this.cookies = null
}

this[kHeadersMap].delete(name)
}

/**
Expand All @@ -279,20 +288,22 @@ class HeadersList {
* @returns {string | null}
*/
get (name) {
const value = this[kHeadersMap].get(name.toLowerCase())

// 1. If list does not contain name, then return null.
// 2. Return the values of all headers in list whose name
// is a byte-case-insensitive match for name,
// separated from each other by 0x2C 0x20, in order.
return value === undefined ? null : value.value
return this[kHeadersMap].get(name.toLowerCase())?.value ?? null
}

/**
* @param {string} name
* @returns {string | null}
*/
lowerCaseGet (name) {
// 1. If list does not contain name, then return null.
// 2. Return the values of all headers in list whose name
// is a byte-case-insensitive match for name,
// separated from each other by 0x2C 0x20, in order.
return this[kHeadersMap].get(name)?.value ?? null
}

Expand Down