summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorNode.js GitHub Bot <github-bot@iojs.org>2023-04-13 13:43:19 +0100
committerGitHub <noreply@github.com>2023-04-13 12:43:19 +0000
commita67cae260267b712f24169ccc09bf181438c9aa3 (patch)
tree9e7f099ca1f28e5f1d07c0674ddb619dde639cfc /deps
parenteb5e9e9d23106d6165eefeae741791bf6e66d262 (diff)
downloadnode-new-a67cae260267b712f24169ccc09bf181438c9aa3.tar.gz
deps: update undici to 5.21.2
PR-URL: https://github.com/nodejs/node/pull/47508 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Diffstat (limited to 'deps')
-rw-r--r--deps/undici/src/lib/core/util.js37
-rw-r--r--deps/undici/src/lib/fetch/headers.js1
-rw-r--r--deps/undici/src/package.json2
-rw-r--r--deps/undici/undici.js26
4 files changed, 47 insertions, 19 deletions
diff --git a/deps/undici/src/lib/core/util.js b/deps/undici/src/lib/core/util.js
index bfee97946c..6f247d22a5 100644
--- a/deps/undici/src/lib/core/util.js
+++ b/deps/undici/src/lib/core/util.js
@@ -222,40 +222,53 @@ function parseHeaders (headers, obj = {}) {
const key = headers[i].toString().toLowerCase()
let val = obj[key]
- const encoding = key.length === 19 && key === 'content-disposition'
- ? 'latin1'
- : 'utf8'
-
if (!val) {
if (Array.isArray(headers[i + 1])) {
obj[key] = headers[i + 1]
} else {
- obj[key] = headers[i + 1].toString(encoding)
+ obj[key] = headers[i + 1].toString('utf8')
}
} else {
if (!Array.isArray(val)) {
val = [val]
obj[key] = val
}
- val.push(headers[i + 1].toString(encoding))
+ val.push(headers[i + 1].toString('utf8'))
}
}
+
+ // See https://github.com/nodejs/node/pull/46528
+ if ('content-length' in obj && 'content-disposition' in obj) {
+ obj['content-disposition'] = Buffer.from(obj['content-disposition']).toString('latin1')
+ }
+
return obj
}
function parseRawHeaders (headers) {
const ret = []
+ let hasContentLength = false
+ let contentDispositionIdx = -1
+
for (let n = 0; n < headers.length; n += 2) {
const key = headers[n + 0].toString()
+ const val = headers[n + 1].toString('utf8')
- const encoding = key.length === 19 && key.toLowerCase() === 'content-disposition'
- ? 'latin1'
- : 'utf8'
-
- const val = headers[n + 1].toString(encoding)
+ if (key.length === 14 && (key === 'content-length' || key.toLowerCase() === 'content-length')) {
+ ret.push(key, val)
+ hasContentLength = true
+ } else if (key.length === 19 && (key === 'content-disposition' || key.toLowerCase() === 'content-disposition')) {
+ contentDispositionIdx = ret.push(key, val) - 1
+ } else {
+ ret.push(key, val)
+ }
+ }
- ret.push(key, val)
+ // See https://github.com/nodejs/node/pull/46528
+ if (hasContentLength && contentDispositionIdx !== -1) {
+ ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString('latin1')
}
+
return ret
}
diff --git a/deps/undici/src/lib/fetch/headers.js b/deps/undici/src/lib/fetch/headers.js
index 5093ef8726..b42a5edeaa 100644
--- a/deps/undici/src/lib/fetch/headers.js
+++ b/deps/undici/src/lib/fetch/headers.js
@@ -95,6 +95,7 @@ class HeadersList {
clear () {
this[kHeadersMap].clear()
this[kHeadersSortedMap] = null
+ this.cookies = null
}
// https://fetch.spec.whatwg.org/#concept-header-list-append
diff --git a/deps/undici/src/package.json b/deps/undici/src/package.json
index 79aa9b2758..f0eb689718 100644
--- a/deps/undici/src/package.json
+++ b/deps/undici/src/package.json
@@ -1,6 +1,6 @@
{
"name": "undici",
- "version": "5.21.1",
+ "version": "5.21.2",
"description": "An HTTP/1.1 client, written from scratch for Node.js",
"homepage": "https://undici.nodejs.org",
"bugs": {
diff --git a/deps/undici/undici.js b/deps/undici/undici.js
index 105d7a83fa..41c18cc725 100644
--- a/deps/undici/undici.js
+++ b/deps/undici/undici.js
@@ -443,30 +443,43 @@ var require_util = __commonJS({
for (let i = 0; i < headers.length; i += 2) {
const key = headers[i].toString().toLowerCase();
let val = obj[key];
- const encoding = key.length === 19 && key === "content-disposition" ? "latin1" : "utf8";
if (!val) {
if (Array.isArray(headers[i + 1])) {
obj[key] = headers[i + 1];
} else {
- obj[key] = headers[i + 1].toString(encoding);
+ obj[key] = headers[i + 1].toString("utf8");
}
} else {
if (!Array.isArray(val)) {
val = [val];
obj[key] = val;
}
- val.push(headers[i + 1].toString(encoding));
+ val.push(headers[i + 1].toString("utf8"));
}
}
+ if ("content-length" in obj && "content-disposition" in obj) {
+ obj["content-disposition"] = Buffer.from(obj["content-disposition"]).toString("latin1");
+ }
return obj;
}
function parseRawHeaders(headers) {
const ret = [];
+ let hasContentLength = false;
+ let contentDispositionIdx = -1;
for (let n = 0; n < headers.length; n += 2) {
const key = headers[n + 0].toString();
- const encoding = key.length === 19 && key.toLowerCase() === "content-disposition" ? "latin1" : "utf8";
- const val = headers[n + 1].toString(encoding);
- ret.push(key, val);
+ const val = headers[n + 1].toString("utf8");
+ if (key.length === 14 && (key === "content-length" || key.toLowerCase() === "content-length")) {
+ ret.push(key, val);
+ hasContentLength = true;
+ } else if (key.length === 19 && (key === "content-disposition" || key.toLowerCase() === "content-disposition")) {
+ contentDispositionIdx = ret.push(key, val) - 1;
+ } else {
+ ret.push(key, val);
+ }
+ }
+ if (hasContentLength && contentDispositionIdx !== -1) {
+ ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString("latin1");
}
return ret;
}
@@ -1765,6 +1778,7 @@ var require_headers = __commonJS({
clear() {
this[kHeadersMap].clear();
this[kHeadersSortedMap] = null;
+ this.cookies = null;
}
append(name, value) {
this[kHeadersSortedMap] = null;