| 11616 | } |
| 11617 | __name(compareHeaderName, "compareHeaderName"); |
| 11618 | var HeadersList = class _HeadersList { |
| 11619 | static { |
| 11620 | __name(this, "HeadersList"); |
| 11621 | } |
| 11622 | /** @type {[string, string][]|null} */ |
| 11623 | cookies = null; |
| 11624 | sortedMap; |
| 11625 | headersMap; |
| 11626 | constructor(init) { |
| 11627 | if (init instanceof _HeadersList) { |
| 11628 | this.headersMap = new Map(init.headersMap); |
| 11629 | this.sortedMap = init.sortedMap; |
| 11630 | this.cookies = init.cookies === null ? null : [...init.cookies]; |
| 11631 | } else { |
| 11632 | this.headersMap = new Map(init); |
| 11633 | this.sortedMap = null; |
| 11634 | } |
| 11635 | } |
| 11636 | /** |
| 11637 | * @see https://fetch.spec.whatwg.org/#header-list-contains |
| 11638 | * @param {string} name |
| 11639 | * @param {boolean} isLowerCase |
| 11640 | */ |
| 11641 | contains(name, isLowerCase) { |
| 11642 | return this.headersMap.has(isLowerCase ? name : name.toLowerCase()); |
| 11643 | } |
| 11644 | clear() { |
| 11645 | this.headersMap.clear(); |
| 11646 | this.sortedMap = null; |
| 11647 | this.cookies = null; |
| 11648 | } |
| 11649 | /** |
| 11650 | * @see https://fetch.spec.whatwg.org/#concept-header-list-append |
| 11651 | * @param {string} name |
| 11652 | * @param {string} value |
| 11653 | * @param {boolean} isLowerCase |
| 11654 | */ |
| 11655 | append(name, value, isLowerCase) { |
| 11656 | this.sortedMap = null; |
| 11657 | const lowercaseName = isLowerCase ? name : name.toLowerCase(); |
| 11658 | const exists = this.headersMap.get(lowercaseName); |
| 11659 | if (exists) { |
| 11660 | const delimiter = lowercaseName === "cookie" ? "; " : ", "; |
| 11661 | this.headersMap.set(lowercaseName, { |
| 11662 | name: exists.name, |
| 11663 | value: `${exists.value}${delimiter}${value}` |
| 11664 | }); |
| 11665 | } else { |
| 11666 | this.headersMap.set(lowercaseName, { name, value }); |
| 11667 | } |
| 11668 | if (lowercaseName === "set-cookie") { |
| 11669 | (this.cookies ??= []).push(value); |
| 11670 | } |
| 11671 | } |
| 11672 | /** |
| 11673 | * @see https://fetch.spec.whatwg.org/#concept-header-list-set |
| 11674 | * @param {string} name |
| 11675 | * @param {string} value |
nothing calls this directly
no test coverage detected
searching dependent graphs…