Skip to content

Commit 90994e6

Browse files
nodejs-github-botjuanarbol
authored andcommitted
deps: update undici to 5.15.1
PR-URL: #46213 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 00302fc commit 90994e6

File tree

7 files changed

+34
-39
lines changed

7 files changed

+34
-39
lines changed

deps/undici/src/lib/client.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ class Parser {
441441

442442
this.keepAlive = ''
443443
this.contentLength = ''
444+
this.connection = ''
444445
this.maxResponseSize = client[kMaxResponseSize]
445446
}
446447

@@ -616,6 +617,8 @@ class Parser {
616617
const key = this.headers[len - 2]
617618
if (key.length === 10 && key.toString().toLowerCase() === 'keep-alive') {
618619
this.keepAlive += buf.toString()
620+
} else if (key.length === 10 && key.toString().toLowerCase() === 'connection') {
621+
this.connection += buf.toString()
619622
} else if (key.length === 14 && key.toString().toLowerCase() === 'content-length') {
620623
this.contentLength += buf.toString()
621624
}
@@ -709,7 +712,11 @@ class Parser {
709712
assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS)
710713

711714
this.statusCode = statusCode
712-
this.shouldKeepAlive = shouldKeepAlive
715+
this.shouldKeepAlive = (
716+
shouldKeepAlive ||
717+
// Override llhttp value which does not allow keepAlive for HEAD.
718+
(request.method === 'HEAD' && !socket[kReset] && this.connection.toLowerCase() === 'keep-alive')
719+
)
713720

714721
if (this.statusCode >= 200) {
715722
const bodyTimeout = request.bodyTimeout != null
@@ -739,7 +746,7 @@ class Parser {
739746
this.headers = []
740747
this.headersSize = 0
741748

742-
if (shouldKeepAlive && client[kPipelining]) {
749+
if (this.shouldKeepAlive && client[kPipelining]) {
743750
const keepAliveTimeout = this.keepAlive ? util.parseKeepAliveTimeout(this.keepAlive) : null
744751

745752
if (keepAliveTimeout != null) {
@@ -769,7 +776,6 @@ class Parser {
769776
}
770777

771778
if (request.method === 'HEAD') {
772-
assert(socket[kReset])
773779
return 1
774780
}
775781

@@ -843,6 +849,7 @@ class Parser {
843849
this.bytesRead = 0
844850
this.contentLength = ''
845851
this.keepAlive = ''
852+
this.connection = ''
846853

847854
assert(this.headers.length % 2 === 0)
848855
this.headers = []
@@ -1376,8 +1383,8 @@ function write (client, request) {
13761383
socket[kReset] = true
13771384
}
13781385

1379-
if (reset) {
1380-
socket[kReset] = true
1386+
if (reset != null) {
1387+
socket[kReset] = reset
13811388
}
13821389

13831390
if (client[kMaxRequests] && socket[kCounter]++ >= client[kMaxRequests]) {

deps/undici/src/lib/core/request.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class Request {
144144

145145
this.blocking = blocking == null ? false : blocking
146146

147-
this.reset = reset == null ? false : reset
147+
this.reset = reset == null ? null : reset
148148

149149
this.host = null
150150

deps/undici/src/lib/fetch/formdata.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ function makeEntry (name, value, filename) {
259259
lastModified: value.lastModified
260260
}
261261

262-
value = value instanceof File
262+
value = (NativeFile && value instanceof NativeFile) || value instanceof UndiciFile
263263
? new File([value], filename, options)
264264
: new FileLike(value, filename, options)
265265
}

deps/undici/src/lib/websocket/websocket.js

+4-13
Original file line numberDiff line numberDiff line change
@@ -309,23 +309,14 @@ class WebSocket extends EventTarget {
309309
// not throw an exception must increase the bufferedAmount attribute
310310
// by the length of data’s buffer in bytes.
311311

312-
const ab = new ArrayBuffer(data.byteLength)
312+
const ab = Buffer.from(data, data.byteOffset, data.byteLength)
313313

314-
if (Buffer.isBuffer(data)) {
315-
// new Buffer signature is deprecated
316-
Buffer.from(ab).set(data)
317-
} else {
318-
new data.constructor(ab).set(data)
319-
}
320-
321-
const value = Buffer.from(ab)
322-
323-
const frame = new WebsocketFrameSend(value)
314+
const frame = new WebsocketFrameSend(ab)
324315
const buffer = frame.createFrame(opcodes.BINARY)
325316

326-
this.#bufferedAmount += value.byteLength
317+
this.#bufferedAmount += ab.byteLength
327318
socket.write(buffer, () => {
328-
this.#bufferedAmount -= value.byteLength
319+
this.#bufferedAmount -= ab.byteLength
329320
})
330321
} else if (isBlobLike(data)) {
331322
// If the WebSocket connection is established, and the WebSocket

deps/undici/src/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "undici",
3-
"version": "5.15.0",
3+
"version": "5.15.1",
44
"description": "An HTTP/1.1 client, written from scratch for Node.js",
55
"homepage": "https://undici.nodejs.org",
66
"bugs": {

deps/undici/undici.js

+14-17
Original file line numberDiff line numberDiff line change
@@ -6088,7 +6088,7 @@ var require_formdata = __commonJS({
60886088
type: value.type,
60896089
lastModified: value.lastModified
60906090
};
6091-
value = value instanceof File ? new File([value], filename, options) : new FileLike(value, filename, options);
6091+
value = NativeFile && value instanceof NativeFile || value instanceof UndiciFile ? new File([value], filename, options) : new FileLike(value, filename, options);
60926092
}
60936093
}
60946094
return { name, value };
@@ -7505,7 +7505,7 @@ var require_request2 = __commonJS({
75057505
this.origin = origin;
75067506
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
75077507
this.blocking = blocking == null ? false : blocking;
7508-
this.reset = reset == null ? false : reset;
7508+
this.reset = reset == null ? null : reset;
75097509
this.host = null;
75107510
this.contentLength = null;
75117511
this.contentType = null;
@@ -8869,6 +8869,7 @@ var require_client = __commonJS({
88698869
this.bytesRead = 0;
88708870
this.keepAlive = "";
88718871
this.contentLength = "";
8872+
this.connection = "";
88728873
this.maxResponseSize = client[kMaxResponseSize];
88738874
}
88748875
setTimeout(value, type) {
@@ -9004,6 +9005,8 @@ var require_client = __commonJS({
90049005
const key = this.headers[len - 2];
90059006
if (key.length === 10 && key.toString().toLowerCase() === "keep-alive") {
90069007
this.keepAlive += buf.toString();
9008+
} else if (key.length === 10 && key.toString().toLowerCase() === "connection") {
9009+
this.connection += buf.toString();
90079010
} else if (key.length === 14 && key.toString().toLowerCase() === "content-length") {
90089011
this.contentLength += buf.toString();
90099012
}
@@ -9067,7 +9070,7 @@ var require_client = __commonJS({
90679070
}
90689071
assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS);
90699072
this.statusCode = statusCode;
9070-
this.shouldKeepAlive = shouldKeepAlive;
9073+
this.shouldKeepAlive = shouldKeepAlive || request.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive";
90719074
if (this.statusCode >= 200) {
90729075
const bodyTimeout = request.bodyTimeout != null ? request.bodyTimeout : client[kBodyTimeout];
90739076
this.setTimeout(bodyTimeout, TIMEOUT_BODY);
@@ -9089,7 +9092,7 @@ var require_client = __commonJS({
90899092
assert(this.headers.length % 2 === 0);
90909093
this.headers = [];
90919094
this.headersSize = 0;
9092-
if (shouldKeepAlive && client[kPipelining]) {
9095+
if (this.shouldKeepAlive && client[kPipelining]) {
90939096
const keepAliveTimeout = this.keepAlive ? util.parseKeepAliveTimeout(this.keepAlive) : null;
90949097
if (keepAliveTimeout != null) {
90959098
const timeout = Math.min(keepAliveTimeout - client[kKeepAliveTimeoutThreshold], client[kKeepAliveMaxTimeout]);
@@ -9112,7 +9115,6 @@ var require_client = __commonJS({
91129115
return -1;
91139116
}
91149117
if (request.method === "HEAD") {
9115-
assert(socket[kReset]);
91169118
return 1;
91179119
}
91189120
if (statusCode < 200) {
@@ -9168,6 +9170,7 @@ var require_client = __commonJS({
91689170
this.bytesRead = 0;
91699171
this.contentLength = "";
91709172
this.keepAlive = "";
9173+
this.connection = "";
91719174
assert(this.headers.length % 2 === 0);
91729175
this.headers = [];
91739176
this.headersSize = 0;
@@ -9534,8 +9537,8 @@ var require_client = __commonJS({
95349537
if (upgrade || method === "CONNECT") {
95359538
socket[kReset] = true;
95369539
}
9537-
if (reset) {
9538-
socket[kReset] = true;
9540+
if (reset != null) {
9541+
socket[kReset] = reset;
95399542
}
95409543
if (client[kMaxRequests] && socket[kCounter]++ >= client[kMaxRequests]) {
95419544
socket[kReset] = true;
@@ -14518,18 +14521,12 @@ var require_websocket = __commonJS({
1451814521
this.#bufferedAmount -= value.byteLength;
1451914522
});
1452014523
} else if (ArrayBuffer.isView(data)) {
14521-
const ab = new ArrayBuffer(data.byteLength);
14522-
if (Buffer.isBuffer(data)) {
14523-
Buffer.from(ab).set(data);
14524-
} else {
14525-
new data.constructor(ab).set(data);
14526-
}
14527-
const value = Buffer.from(ab);
14528-
const frame = new WebsocketFrameSend(value);
14524+
const ab = Buffer.from(data, data.byteOffset, data.byteLength);
14525+
const frame = new WebsocketFrameSend(ab);
1452914526
const buffer = frame.createFrame(opcodes.BINARY);
14530-
this.#bufferedAmount += value.byteLength;
14527+
this.#bufferedAmount += ab.byteLength;
1453114528
socket.write(buffer, () => {
14532-
this.#bufferedAmount -= value.byteLength;
14529+
this.#bufferedAmount -= ab.byteLength;
1453314530
});
1453414531
} else if (isBlobLike(data)) {
1453514532
const frame = new WebsocketFrameSend();

src/undici_version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
// Refer to tools/update-undici.sh
33
#ifndef SRC_UNDICI_VERSION_H_
44
#define SRC_UNDICI_VERSION_H_
5-
#define UNDICI_VERSION "5.15.0"
5+
#define UNDICI_VERSION "5.15.1"
66
#endif // SRC_UNDICI_VERSION_H_

0 commit comments

Comments
 (0)