Skip to content

Commit ede69d2

Browse files
nodejs-github-bottargos
authored andcommitted
deps: update undici to 5.21.2
PR-URL: #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>
1 parent 64b5a5f commit ede69d2

5 files changed

Lines changed: 48 additions & 20 deletions

File tree

‎deps/undici/src/lib/core/util.js‎

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -222,40 +222,53 @@ function parseHeaders (headers, obj = {}) {
222222
constkey=headers[i].toString().toLowerCase()
223223
letval=obj[key]
224224

225-
constencoding=key.length===19&&key==='content-disposition'
226-
? 'latin1'
227-
: 'utf8'
228-
229225
if(!val){
230226
if(Array.isArray(headers[i+1])){
231227
obj[key]=headers[i+1]
232228
}else{
233-
obj[key]=headers[i+1].toString(encoding)
229+
obj[key]=headers[i+1].toString('utf8')
234230
}
235231
}else{
236232
if(!Array.isArray(val)){
237233
val=[val]
238234
obj[key]=val
239235
}
240-
val.push(headers[i+1].toString(encoding))
236+
val.push(headers[i+1].toString('utf8'))
241237
}
242238
}
239+
240+
// See https://github.com/nodejs/node/pull/46528
241+
if('content-length'inobj&&'content-disposition'inobj){
242+
obj['content-disposition']=Buffer.from(obj['content-disposition']).toString('latin1')
243+
}
244+
243245
returnobj
244246
}
245247

246248
functionparseRawHeaders(headers){
247249
constret=[]
250+
lethasContentLength=false
251+
letcontentDispositionIdx=-1
252+
248253
for(letn=0;n<headers.length;n+=2){
249254
constkey=headers[n+0].toString()
255+
constval=headers[n+1].toString('utf8')
250256

251-
constencoding=key.length===19&&key.toLowerCase()==='content-disposition'
252-
? 'latin1'
253-
: 'utf8'
254-
255-
constval=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+
}elseif(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+
}
256266

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')
258270
}
271+
259272
returnret
260273
}
261274

‎deps/undici/src/lib/fetch/headers.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class HeadersList {
9595
clear(){
9696
this[kHeadersMap].clear()
9797
this[kHeadersSortedMap]=null
98+
this.cookies=null
9899
}
99100

100101
// https://fetch.spec.whatwg.org/#concept-header-list-append

‎deps/undici/src/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "undici",
3-
"version": "5.21.1",
3+
"version": "5.21.2",
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‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,30 +443,43 @@ var require_util = __commonJS({
443443
for(leti=0;i<headers.length;i+=2){
444444
constkey=headers[i].toString().toLowerCase();
445445
letval=obj[key];
446-
constencoding=key.length===19&&key==="content-disposition" ? "latin1" : "utf8";
447446
if(!val){
448447
if(Array.isArray(headers[i+1])){
449448
obj[key]=headers[i+1];
450449
}else{
451-
obj[key]=headers[i+1].toString(encoding);
450+
obj[key]=headers[i+1].toString("utf8");
452451
}
453452
}else{
454453
if(!Array.isArray(val)){
455454
val=[val];
456455
obj[key]=val;
457456
}
458-
val.push(headers[i+1].toString(encoding));
457+
val.push(headers[i+1].toString("utf8"));
459458
}
460459
}
460+
if("content-length"inobj&&"content-disposition"inobj){
461+
obj["content-disposition"]=Buffer.from(obj["content-disposition"]).toString("latin1");
462+
}
461463
returnobj;
462464
}
463465
functionparseRawHeaders(headers){
464466
constret=[];
467+
lethasContentLength=false;
468+
letcontentDispositionIdx=-1;
465469
for(letn=0;n<headers.length;n+=2){
466470
constkey=headers[n+0].toString();
467-
constencoding=key.length===19&&key.toLowerCase()==="content-disposition" ? "latin1" : "utf8";
468-
constval=headers[n+1].toString(encoding);
469-
ret.push(key,val);
471+
constval=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+
}elseif(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");
470483
}
471484
returnret;
472485
}
@@ -1765,6 +1778,7 @@ var require_headers = __commonJS({
17651778
clear(){
17661779
this[kHeadersMap].clear();
17671780
this[kHeadersSortedMap]=null;
1781+
this.cookies=null;
17681782
}
17691783
append(name,value){
17701784
this[kHeadersSortedMap]=null;

‎src/undici_version.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
// Refer to tools/update-undici.sh
33
#ifndefSRC_UNDICI_VERSION_H_
44
#defineSRC_UNDICI_VERSION_H_
5-
#defineUNDICI_VERSION "5.21.1"
5+
#defineUNDICI_VERSION "5.21.2"
66
#endif// SRC_UNDICI_VERSION_H_

0 commit comments

Comments
 (0)