Skip to content

Commit

Permalink
deps: update undici to 5.15.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nodejs-github-bot committed Jan 22, 2023
1 parent 534b09b commit 323d837
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 39 deletions.
17 changes: 12 additions & 5 deletions deps/undici/src/lib/client.js
Expand Up @@ -441,6 +441,7 @@ class Parser {

this.keepAlive = ''
this.contentLength = ''
this.connection = ''
this.maxResponseSize = client[kMaxResponseSize]
}

Expand Down Expand Up @@ -616,6 +617,8 @@ class Parser {
const key = this.headers[len - 2]
if (key.length === 10 && key.toString().toLowerCase() === 'keep-alive') {
this.keepAlive += buf.toString()
} else if (key.length === 10 && key.toString().toLowerCase() === 'connection') {
this.connection += buf.toString()
} else if (key.length === 14 && key.toString().toLowerCase() === 'content-length') {
this.contentLength += buf.toString()
}
Expand Down Expand Up @@ -709,7 +712,11 @@ class Parser {
assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS)

this.statusCode = statusCode
this.shouldKeepAlive = shouldKeepAlive
this.shouldKeepAlive = (
shouldKeepAlive ||
// Override llhttp value which does not allow keepAlive for HEAD.
(request.method === 'HEAD' && !socket[kReset] && this.connection.toLowerCase() === 'keep-alive')
)

if (this.statusCode >= 200) {
const bodyTimeout = request.bodyTimeout != null
Expand Down Expand Up @@ -739,7 +746,7 @@ class Parser {
this.headers = []
this.headersSize = 0

if (shouldKeepAlive && client[kPipelining]) {
if (this.shouldKeepAlive && client[kPipelining]) {
const keepAliveTimeout = this.keepAlive ? util.parseKeepAliveTimeout(this.keepAlive) : null

if (keepAliveTimeout != null) {
Expand Down Expand Up @@ -769,7 +776,6 @@ class Parser {
}

if (request.method === 'HEAD') {
assert(socket[kReset])
return 1
}

Expand Down Expand Up @@ -843,6 +849,7 @@ class Parser {
this.bytesRead = 0
this.contentLength = ''
this.keepAlive = ''
this.connection = ''

assert(this.headers.length % 2 === 0)
this.headers = []
Expand Down Expand Up @@ -1376,8 +1383,8 @@ function write (client, request) {
socket[kReset] = true
}

if (reset) {
socket[kReset] = true
if (reset != null) {
socket[kReset] = reset
}

if (client[kMaxRequests] && socket[kCounter]++ >= client[kMaxRequests]) {
Expand Down
2 changes: 1 addition & 1 deletion deps/undici/src/lib/core/request.js
Expand Up @@ -144,7 +144,7 @@ class Request {

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

this.reset = reset == null ? false : reset
this.reset = reset == null ? null : reset

this.host = null

Expand Down
2 changes: 1 addition & 1 deletion deps/undici/src/lib/fetch/formdata.js
Expand Up @@ -259,7 +259,7 @@ function makeEntry (name, value, filename) {
lastModified: value.lastModified
}

value = value instanceof File
value = (NativeFile && value instanceof NativeFile) || value instanceof UndiciFile
? new File([value], filename, options)
: new FileLike(value, filename, options)
}
Expand Down
17 changes: 4 additions & 13 deletions deps/undici/src/lib/websocket/websocket.js
Expand Up @@ -309,23 +309,14 @@ class WebSocket extends EventTarget {
// not throw an exception must increase the bufferedAmount attribute
// by the length of data’s buffer in bytes.

const ab = new ArrayBuffer(data.byteLength)
const ab = Buffer.from(data, data.byteOffset, data.byteLength)

if (Buffer.isBuffer(data)) {
// new Buffer signature is deprecated
Buffer.from(ab).set(data)
} else {
new data.constructor(ab).set(data)
}

const value = Buffer.from(ab)

const frame = new WebsocketFrameSend(value)
const frame = new WebsocketFrameSend(ab)
const buffer = frame.createFrame(opcodes.BINARY)

this.#bufferedAmount += value.byteLength
this.#bufferedAmount += ab.byteLength
socket.write(buffer, () => {
this.#bufferedAmount -= value.byteLength
this.#bufferedAmount -= ab.byteLength
})
} else if (isBlobLike(data)) {
// If the WebSocket connection is established, and the WebSocket
Expand Down
2 changes: 1 addition & 1 deletion deps/undici/src/package.json
@@ -1,6 +1,6 @@
{
"name": "undici",
"version": "5.15.0",
"version": "5.15.1",
"description": "An HTTP/1.1 client, written from scratch for Node.js",
"homepage": "https://undici.nodejs.org",
"bugs": {
Expand Down
31 changes: 14 additions & 17 deletions deps/undici/undici.js
Expand Up @@ -6088,7 +6088,7 @@ var require_formdata = __commonJS({
type: value.type,
lastModified: value.lastModified
};
value = value instanceof File ? new File([value], filename, options) : new FileLike(value, filename, options);
value = NativeFile && value instanceof NativeFile || value instanceof UndiciFile ? new File([value], filename, options) : new FileLike(value, filename, options);
}
}
return { name, value };
Expand Down Expand Up @@ -7505,7 +7505,7 @@ var require_request2 = __commonJS({
this.origin = origin;
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
this.blocking = blocking == null ? false : blocking;
this.reset = reset == null ? false : reset;
this.reset = reset == null ? null : reset;
this.host = null;
this.contentLength = null;
this.contentType = null;
Expand Down Expand Up @@ -8869,6 +8869,7 @@ var require_client = __commonJS({
this.bytesRead = 0;
this.keepAlive = "";
this.contentLength = "";
this.connection = "";
this.maxResponseSize = client[kMaxResponseSize];
}
setTimeout(value, type) {
Expand Down Expand Up @@ -9004,6 +9005,8 @@ var require_client = __commonJS({
const key = this.headers[len - 2];
if (key.length === 10 && key.toString().toLowerCase() === "keep-alive") {
this.keepAlive += buf.toString();
} else if (key.length === 10 && key.toString().toLowerCase() === "connection") {
this.connection += buf.toString();
} else if (key.length === 14 && key.toString().toLowerCase() === "content-length") {
this.contentLength += buf.toString();
}
Expand Down Expand Up @@ -9067,7 +9070,7 @@ var require_client = __commonJS({
}
assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS);
this.statusCode = statusCode;
this.shouldKeepAlive = shouldKeepAlive;
this.shouldKeepAlive = shouldKeepAlive || request.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive";
if (this.statusCode >= 200) {
const bodyTimeout = request.bodyTimeout != null ? request.bodyTimeout : client[kBodyTimeout];
this.setTimeout(bodyTimeout, TIMEOUT_BODY);
Expand All @@ -9089,7 +9092,7 @@ var require_client = __commonJS({
assert(this.headers.length % 2 === 0);
this.headers = [];
this.headersSize = 0;
if (shouldKeepAlive && client[kPipelining]) {
if (this.shouldKeepAlive && client[kPipelining]) {
const keepAliveTimeout = this.keepAlive ? util.parseKeepAliveTimeout(this.keepAlive) : null;
if (keepAliveTimeout != null) {
const timeout = Math.min(keepAliveTimeout - client[kKeepAliveTimeoutThreshold], client[kKeepAliveMaxTimeout]);
Expand All @@ -9112,7 +9115,6 @@ var require_client = __commonJS({
return -1;
}
if (request.method === "HEAD") {
assert(socket[kReset]);
return 1;
}
if (statusCode < 200) {
Expand Down Expand Up @@ -9168,6 +9170,7 @@ var require_client = __commonJS({
this.bytesRead = 0;
this.contentLength = "";
this.keepAlive = "";
this.connection = "";
assert(this.headers.length % 2 === 0);
this.headers = [];
this.headersSize = 0;
Expand Down Expand Up @@ -9534,8 +9537,8 @@ var require_client = __commonJS({
if (upgrade || method === "CONNECT") {
socket[kReset] = true;
}
if (reset) {
socket[kReset] = true;
if (reset != null) {
socket[kReset] = reset;
}
if (client[kMaxRequests] && socket[kCounter]++ >= client[kMaxRequests]) {
socket[kReset] = true;
Expand Down Expand Up @@ -14518,18 +14521,12 @@ var require_websocket = __commonJS({
this.#bufferedAmount -= value.byteLength;
});
} else if (ArrayBuffer.isView(data)) {
const ab = new ArrayBuffer(data.byteLength);
if (Buffer.isBuffer(data)) {
Buffer.from(ab).set(data);
} else {
new data.constructor(ab).set(data);
}
const value = Buffer.from(ab);
const frame = new WebsocketFrameSend(value);
const ab = Buffer.from(data, data.byteOffset, data.byteLength);
const frame = new WebsocketFrameSend(ab);
const buffer = frame.createFrame(opcodes.BINARY);
this.#bufferedAmount += value.byteLength;
this.#bufferedAmount += ab.byteLength;
socket.write(buffer, () => {
this.#bufferedAmount -= value.byteLength;
this.#bufferedAmount -= ab.byteLength;
});
} else if (isBlobLike(data)) {
const frame = new WebsocketFrameSend();
Expand Down
2 changes: 1 addition & 1 deletion src/undici_version.h
Expand Up @@ -2,5 +2,5 @@
// Refer to tools/update-undici.sh
#ifndef SRC_UNDICI_VERSION_H_
#define SRC_UNDICI_VERSION_H_
#define UNDICI_VERSION "5.15.0"
#define UNDICI_VERSION "5.15.1"
#endif // SRC_UNDICI_VERSION_H_

0 comments on commit 323d837

Please sign in to comment.