| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dcb8c03 commit f532f9d
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -222,40 +222,53 @@ function parseHeaders (headers, obj = {}) { | |||
| 222 | 222 | const key = headers[i].toString().toLowerCase() | |
| 223 | 223 | let val = obj[key] | |
| 224 | 224 | ||
| 225 | - const encoding = key.length === 19 && key === 'content-disposition' | ||
| 226 | - ? 'latin1' | ||
| 227 | - : 'utf8' | ||
| 228 | - | ||
| 229 | 225 | if (!val) { | |
| 230 | 226 | if (Array.isArray(headers[i + 1])) { | |
| 231 | 227 | obj[key] = headers[i + 1] | |
| 232 | 228 | } else { | |
| 233 | - obj[key] = headers[i + 1].toString(encoding) | ||
| 229 | + obj[key] = headers[i + 1].toString('utf8') | ||
| 234 | 230 | } | |
| 235 | 231 | } else { | |
| 236 | 232 | if (!Array.isArray(val)) { | |
| 237 | 233 | val = [val] | |
| 238 | 234 | obj[key] = val | |
| 239 | 235 | } | |
| 240 | - val.push(headers[i + 1].toString(encoding)) | ||
| 236 | + val.push(headers[i + 1].toString('utf8')) | ||
| 241 | 237 | } | |
| 242 | 238 | } | |
| 239 | + | ||
| 240 | + // See https://github.com/nodejs/node/pull/46528 | ||
| 241 | + if ('content-length' in obj && 'content-disposition' in obj) { | ||
| 242 | + obj['content-disposition'] = Buffer.from(obj['content-disposition']).toString('latin1') | ||
| 243 | + } | ||
| 244 | + | ||
| 243 | 245 | return obj | |
| 244 | 246 | } | |
| 245 | 247 | ||
| 246 | 248 | function parseRawHeaders (headers) { | |
| 247 | 249 | const ret = [] | |
| 250 | + let hasContentLength = false | ||
| 251 | + let contentDispositionIdx = -1 | ||
| 252 | + | ||
| 248 | 253 | for (let n = 0; n < headers.length; n += 2) { | |
| 249 | 254 | const key = headers[n + 0].toString() | |
| 255 | + const val = headers[n + 1].toString('utf8') | ||
| 250 | 256 | ||
| 251 | - const encoding = key.length === 19 && key.toLowerCase() === 'content-disposition' | ||
| 252 | - ? 'latin1' | ||
| 253 | - : 'utf8' | ||
| 254 | - | ||
| 255 | - const val = headers[n + 1].toString(encoding) | ||
| 257 | + if (key.length === 14 && (key === 'content-length' || key.toLowerCase() === 'content-length')) { | ||
| 258 | + ret.push(key, val) | ||
| 259 | + hasContentLength = true | ||
| 260 | + } else if (key.length === 19 && (key === 'content-disposition' || key.toLowerCase() === 'content-disposition')) { | ||
| 261 | + contentDispositionIdx = ret.push(key, val) - 1 | ||
| 262 | + } else { | ||
| 263 | + ret.push(key, val) | ||
| 264 | + } | ||
| 265 | + } | ||
| 256 | 266 | ||
| 257 | - ret.push(key, val) | ||
| 267 | + // See https://github.com/nodejs/node/pull/46528 | ||
| 268 | + if (hasContentLength && contentDispositionIdx !== -1) { | ||
| 269 | + ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString('latin1') | ||
| 258 | 270 | } | |
| 271 | + | ||
| 259 | 272 | return ret | |
| 260 | 273 | } | |
| 261 | 274 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -95,6 +95,7 @@ class HeadersList { | |||
| 95 | 95 | clear () { | |
| 96 | 96 | this[kHeadersMap].clear() | |
| 97 | 97 | this[kHeadersSortedMap] = null | |
| 98 | + this.cookies = null | ||
| 98 | 99 | } | |
| 99 | 100 | ||
| 100 | 101 | // https://fetch.spec.whatwg.org/#concept-header-list-append | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | { | |
| 2 | 2 | "name": "undici", | |
| 3 | - "version": "5.21.1", | ||
| 3 | + "version": "5.21.2", | ||
| 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 | |
|---|---|---|---|
@@ -443,30 +443,43 @@ var require_util = __commonJS({ | |||
| 443 | 443 | for (let i = 0; i < headers.length; i += 2) { | |
| 444 | 444 | const key = headers[i].toString().toLowerCase(); | |
| 445 | 445 | let val = obj[key]; | |
| 446 | - const encoding = key.length === 19 && key === "content-disposition" ? "latin1" : "utf8"; | ||
| 447 | 446 | if (!val) { | |
| 448 | 447 | if (Array.isArray(headers[i + 1])) { | |
| 449 | 448 | obj[key] = headers[i + 1]; | |
| 450 | 449 | } else { | |
| 451 | - obj[key] = headers[i + 1].toString(encoding); | ||
| 450 | + obj[key] = headers[i + 1].toString("utf8"); | ||
| 452 | 451 | } | |
| 453 | 452 | } else { | |
| 454 | 453 | if (!Array.isArray(val)) { | |
| 455 | 454 | val = [val]; | |
| 456 | 455 | obj[key] = val; | |
| 457 | 456 | } | |
| 458 | - val.push(headers[i + 1].toString(encoding)); | ||
| 457 | + val.push(headers[i + 1].toString("utf8")); | ||
| 459 | 458 | } | |
| 460 | 459 | } | |
| 460 | + if ("content-length" in obj && "content-disposition" in obj) { | ||
| 461 | + obj["content-disposition"] = Buffer.from(obj["content-disposition"]).toString("latin1"); | ||
| 462 | + } | ||
| 461 | 463 | return obj; | |
| 462 | 464 | } | |
| 463 | 465 | function parseRawHeaders(headers) { | |
| 464 | 466 | const ret = []; | |
| 467 | + let hasContentLength = false; | ||
| 468 | + let contentDispositionIdx = -1; | ||
| 465 | 469 | for (let n = 0; n < headers.length; n += 2) { | |
| 466 | 470 | const key = headers[n + 0].toString(); | |
| 467 | - const encoding = key.length === 19 && key.toLowerCase() === "content-disposition" ? "latin1" : "utf8"; | ||
| 468 | - const val = headers[n + 1].toString(encoding); | ||
| 469 | - ret.push(key, val); | ||
| 471 | + const val = headers[n + 1].toString("utf8"); | ||
| 472 | + if (key.length === 14 && (key === "content-length" || key.toLowerCase() === "content-length")) { | ||
| 473 | + ret.push(key, val); | ||
| 474 | + hasContentLength = true; | ||
| 475 | + } else if (key.length === 19 && (key === "content-disposition" || key.toLowerCase() === "content-disposition")) { | ||
| 476 | + contentDispositionIdx = ret.push(key, val) - 1; | ||
| 477 | + } else { | ||
| 478 | + ret.push(key, val); | ||
| 479 | + } | ||
| 480 | + } | ||
| 481 | + if (hasContentLength && contentDispositionIdx !== -1) { | ||
| 482 | + ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString("latin1"); | ||
| 470 | 483 | } | |
| 471 | 484 | return ret; | |
| 472 | 485 | } | |
@@ -1765,6 +1778,7 @@ var require_headers = __commonJS({ | |||
| 1765 | 1778 | clear() { | |
| 1766 | 1779 | this[kHeadersMap].clear(); | |
| 1767 | 1780 | this[kHeadersSortedMap] = null; | |
| 1781 | + this.cookies = null; | ||
| 1768 | 1782 | } | |
| 1769 | 1783 | append(name, value) { | |
| 1770 | 1784 | this[kHeadersSortedMap] = null; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,5 +2,5 @@ | |||
| 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.21.1" | ||
| 5 | + #define UNDICI_VERSION "5.21.2" | ||
| 6 | 6 | #endif // SRC_UNDICI_VERSION_H_ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments