File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11'use strict'
22
33const { parseSetCookie } = require ( './parse' )
4- const { stringify, getHeadersList } = require ( './util' )
4+ const { stringify } = require ( './util' )
55const { webidl } = require ( '../fetch/webidl' )
66const { Headers } = require ( '../fetch/headers' )
77
@@ -78,14 +78,13 @@ function getSetCookies (headers) {
7878
7979 webidl . brandCheck ( headers , Headers , { strict : false } )
8080
81- const cookies = getHeadersList ( headers ) . cookies
81+ const cookies = headers . getSetCookie ( )
8282
8383 if ( ! cookies ) {
8484 return [ ]
8585 }
8686
87- // In older versions of undici, cookies is a list of name:value.
88- return cookies . map ( ( pair ) => parseSetCookie ( Array . isArray ( pair ) ? pair [ 1 ] : pair ) )
87+ return cookies . map ( ( pair ) => parseSetCookie ( pair ) )
8988}
9089
9190/**
Original file line number Diff line number Diff line change 11'use strict'
22
3- const assert = require ( 'node:assert' )
4- const { getHeadersList : internalGetHeadersList } = require ( '../fetch/headers' )
5-
63/**
74 * @param {string } value
85 * @returns {boolean }
@@ -275,35 +272,11 @@ function stringify (cookie) {
275272 return out . join ( '; ' )
276273}
277274
278- let kHeadersListNode
279-
280- function getHeadersList ( headers ) {
281- try {
282- return internalGetHeadersList ( headers )
283- } catch {
284- // fall-through
285- }
286-
287- if ( ! kHeadersListNode ) {
288- kHeadersListNode = Object . getOwnPropertySymbols ( headers ) . find (
289- ( symbol ) => symbol . description === 'headers list'
290- )
291-
292- assert ( kHeadersListNode , 'Headers cannot be parsed' )
293- }
294-
295- const headersList = headers [ kHeadersListNode ]
296- assert ( headersList )
297-
298- return headersList
299- }
300-
301275module . exports = {
302276 isCTLExcludingHtab,
303277 validateCookieName,
304278 validateCookiePath,
305279 validateCookieValue,
306280 toIMFDate,
307- stringify,
308- getHeadersList
281+ stringify
309282}
Original file line number Diff line number Diff line change @@ -641,14 +641,6 @@ Object.defineProperties(Headers.prototype, {
641641 } ,
642642 [ util . inspect . custom ] : {
643643 enumerable : false
644- } ,
645- // Compatibility for global headers
646- [ Symbol ( 'headers list' ) ] : {
647- configurable : false ,
648- enumerable : false ,
649- get : function ( ) {
650- return getHeadersList ( this )
651- }
652644 }
653645} )
654646
Original file line number Diff line number Diff line change 88 getSetCookies,
99 setCookie
1010} = require ( '../..' )
11- const { getHeadersList } = require ( '../../lib/web/cookies/util' )
1211
1312describe ( 'Using global Headers' , async ( ) => {
1413 test ( 'deleteCookies' , ( ) => {
@@ -32,7 +31,7 @@ describe('Using global Headers', async () => {
3231 'set-cookie' : 'undici=getSetCookies; Secure'
3332 } )
3433
35- const supportsCookies = getHeadersList ( headers ) . cookies
34+ const supportsCookies = headers . getSetCookie ( )
3635
3736 if ( ! supportsCookies ) {
3837 assert . deepEqual ( getSetCookies ( headers ) , [ ] )
You can’t perform that action at this time.
0 commit comments