File tree 7 files changed +44
-32
lines changed
7 files changed +44
-32
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
3
const { parseSetCookie } = require ( './parse' )
4
- const { stringify, getHeadersList } = require ( './util' )
4
+ const { stringify } = require ( './util' )
5
5
const { webidl } = require ( '../fetch/webidl' )
6
6
const { Headers } = require ( '../fetch/headers' )
7
7
@@ -77,14 +77,13 @@ function getSetCookies (headers) {
77
77
78
78
webidl . brandCheck ( headers , Headers , { strict : false } )
79
79
80
- const cookies = getHeadersList ( headers ) . cookies
80
+ const cookies = headers . getSetCookie ( )
81
81
82
82
if ( ! cookies ) {
83
83
return [ ]
84
84
}
85
85
86
- // In older versions of undici, cookies is a list of name:value.
87
- return cookies . map ( ( pair ) => parseSetCookie ( Array . isArray ( pair ) ? pair [ 1 ] : pair ) )
86
+ return cookies . map ( ( pair ) => parseSetCookie ( pair ) )
88
87
}
89
88
90
89
/**
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const assert = require ( 'assert' )
4
- const { kHeadersList } = require ( '../core/symbols' )
5
-
3
+ /**
4
+ * @param {string } value
5
+ * @returns {boolean }
6
+ */
6
7
function isCTLExcludingHtab ( value ) {
7
8
if ( value . length === 0 ) {
8
9
return false
@@ -263,29 +264,11 @@ function stringify (cookie) {
263
264
return out . join ( '; ' )
264
265
}
265
266
266
- let kHeadersListNode
267
-
268
- function getHeadersList ( headers ) {
269
- if ( headers [ kHeadersList ] ) {
270
- return headers [ kHeadersList ]
271
- }
272
-
273
- if ( ! kHeadersListNode ) {
274
- kHeadersListNode = Object . getOwnPropertySymbols ( headers ) . find (
275
- ( symbol ) => symbol . description === 'headers list'
276
- )
277
-
278
- assert ( kHeadersListNode , 'Headers cannot be parsed' )
279
- }
280
-
281
- const headersList = headers [ kHeadersListNode ]
282
- assert ( headersList )
283
-
284
- return headersList
285
- }
286
-
287
267
module . exports = {
288
268
isCTLExcludingHtab,
289
- stringify,
290
- getHeadersList
269
+ validateCookieName,
270
+ validateCookiePath,
271
+ validateCookieValue,
272
+ toIMFDate,
273
+ stringify
291
274
}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const {
10
10
isValidHeaderName,
11
11
isValidHeaderValue
12
12
} = require ( './util' )
13
+ const util = require ( 'util' )
13
14
const { webidl } = require ( './webidl' )
14
15
const assert = require ( 'assert' )
15
16
@@ -563,6 +564,9 @@ Object.defineProperties(Headers.prototype, {
563
564
[ Symbol . toStringTag ] : {
564
565
value : 'Headers' ,
565
566
configurable : true
567
+ } ,
568
+ [ util . inspect . custom ] : {
569
+ enumerable : false
566
570
}
567
571
} )
568
572
Original file line number Diff line number Diff line change @@ -73,6 +73,20 @@ class Pool extends PoolBase {
73
73
? { ...options . interceptors }
74
74
: undefined
75
75
this [ kFactory ] = factory
76
+
77
+ this . on ( 'connectionError' , ( origin , targets , error ) => {
78
+ // If a connection error occurs, we remove the client from the pool,
79
+ // and emit a connectionError event. They will not be re-used.
80
+ // Fixes https://github.com/nodejs/undici/issues/3895
81
+ for ( const target of targets ) {
82
+ // Do not use kRemoveClient here, as it will close the client,
83
+ // but the client cannot be closed in this state.
84
+ const idx = this [ kClients ] . indexOf ( target )
85
+ if ( idx !== - 1 ) {
86
+ this [ kClients ] . splice ( idx , 1 )
87
+ }
88
+ }
89
+ } )
76
90
}
77
91
78
92
[ kGetDispatcher ] ( ) {
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " undici" ,
3
- "version" : " 5.28.5 " ,
3
+ "version" : " 5.29.0 " ,
4
4
"description" : " An HTTP/1.1 client, written from scratch for Node.js" ,
5
5
"homepage" : " https://undici.nodejs.org" ,
6
6
"bugs" : {
Original file line number Diff line number Diff line change @@ -2168,6 +2168,7 @@ var require_headers = __commonJS({
2168
2168
isValidHeaderName,
2169
2169
isValidHeaderValue
2170
2170
} = require_util2();
2171
+ var util = require("util");
2171
2172
var { webidl } = require_webidl();
2172
2173
var assert = require("assert");
2173
2174
var kHeadersMap = Symbol("headers map");
@@ -2531,6 +2532,9 @@ var require_headers = __commonJS({
2531
2532
[Symbol.toStringTag]: {
2532
2533
value: "Headers",
2533
2534
configurable: true
2535
+ },
2536
+ [util.inspect.custom]: {
2537
+ enumerable: false
2534
2538
}
2535
2539
});
2536
2540
webidl.converters.HeadersInit = function(V) {
@@ -10122,6 +10126,14 @@ var require_pool = __commonJS({
10122
10126
this[kOptions] = { ...util.deepClone(options), connect, allowH2 };
10123
10127
this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
10124
10128
this[kFactory] = factory;
10129
+ this.on("connectionError", (origin2, targets, error) => {
10130
+ for (const target of targets) {
10131
+ const idx = this[kClients].indexOf(target);
10132
+ if (idx !== -1) {
10133
+ this[kClients].splice(idx, 1);
10134
+ }
10135
+ }
10136
+ });
10125
10137
}
10126
10138
[kGetDispatcher]() {
10127
10139
let dispatcher = this[kClients].find((dispatcher2) => !dispatcher2[kNeedDrain]);
Original file line number Diff line number Diff line change 2
2
// Refer to tools/update-undici.sh
3
3
#ifndef SRC_UNDICI_VERSION_H_
4
4
#define SRC_UNDICI_VERSION_H_
5
- #define UNDICI_VERSION "5.28.5 "
5
+ #define UNDICI_VERSION "5.29.0 "
6
6
#endif // SRC_UNDICI_VERSION_H_
You can’t perform that action at this time.
0 commit comments