Skip to content

Commit 0b40bfa

Browse files
nodejs-github-bottargos
authored andcommitted
deps: update undici to 6.19.0
PR-URL: #53468 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent bcad560 commit 0b40bfa

16 files changed

Lines changed: 455 additions & 415 deletions

File tree

‎deps/undici/src/docs/docs/api/Client.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Returns: `Client`
1919

2020
> ⚠️ Warning: The `H2` support is experimental.
2121
22-
***bodyTimeout**`number | null` (optional) - Default: `300e3` - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 300 seconds.
22+
***bodyTimeout**`number | null` (optional) - Default: `300e3` - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 300 seconds. Please note the `timeout` will be reset if you keep writing data to the scoket everytime.
2323
***headersTimeout**`number | null` (optional) - Default: `300e3` - The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers while not sending the request. Defaults to 300 seconds.
2424
***keepAliveMaxTimeout**`number | null` (optional) - Default: `600e3` - The maximum allowed `keepAliveTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Defaults to 10 minutes.
2525
***keepAliveTimeout**`number | null` (optional) - Default: `4e3` - The timeout, in milliseconds, after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. See [MDN: HTTP - Headers - Keep-Alive directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive#directives) for more details. Defaults to 4 seconds.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env
7373
}
7474
}
7575

76-
functionbuildConnector({ allowH2, maxCachedSessions, socketPath, timeout, ...opts}){
76+
functionbuildConnector({ allowH2, maxCachedSessions, socketPath, timeout,session: customSession,...opts}){
7777
if(maxCachedSessions!=null&&(!Number.isInteger(maxCachedSessions)||maxCachedSessions<0)){
7878
thrownewInvalidArgumentError('maxCachedSessions must be a positive integer or zero')
7979
}
@@ -91,7 +91,7 @@ function buildConnector ({ allowH2, maxCachedSessions, socketPath, timeout, ...o
9191
servername=servername||options.servername||util.getServerName(host)||null
9292

9393
constsessionKey=servername||hostname
94-
constsession=sessionCache.get(sessionKey)||null
94+
constsession=customSession||sessionCache.get(sessionKey)||null
9595

9696
assert(sessionKey)
9797

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const {
1616
isBlobLike,
1717
buildURL,
1818
validateHandler,
19-
getServerName
19+
getServerName,
20+
normalizedMethodRecords
2021
}=require('./util')
2122
const{ channels }=require('./diagnostics.js')
2223
const{ headerNameLowerCasedRecord }=require('./constants')
@@ -51,13 +52,13 @@ class Request {
5152
method!=='CONNECT'
5253
){
5354
thrownewInvalidArgumentError('path must be an absolute URL or start with a slash')
54-
}elseif(invalidPathRegex.exec(path)!==null){
55+
}elseif(invalidPathRegex.test(path)){
5556
thrownewInvalidArgumentError('invalid request path')
5657
}
5758

5859
if(typeofmethod!=='string'){
5960
thrownewInvalidArgumentError('method must be a string')
60-
}elseif(!isValidHTTPToken(method)){
61+
}elseif(normalizedMethodRecords[method]===undefined&&!isValidHTTPToken(method)){
6162
thrownewInvalidArgumentError('invalid request method')
6263
}
6364

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,31 @@ function errorRequest (client, request, err) {
645645
constkEnumerableProperty=Object.create(null)
646646
kEnumerableProperty.enumerable=true
647647

648+
constnormalizedMethodRecordsBase={
649+
delete: 'DELETE',
650+
DELETE: 'DELETE',
651+
get: 'GET',
652+
GET: 'GET',
653+
head: 'HEAD',
654+
HEAD: 'HEAD',
655+
options: 'OPTIONS',
656+
OPTIONS: 'OPTIONS',
657+
post: 'POST',
658+
POST: 'POST',
659+
put: 'PUT',
660+
PUT: 'PUT'
661+
}
662+
663+
constnormalizedMethodRecords={
664+
...normalizedMethodRecordsBase,
665+
patch: 'patch',
666+
PATCH: 'PATCH'
667+
}
668+
669+
// Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`.
670+
Object.setPrototypeOf(normalizedMethodRecordsBase,null)
671+
Object.setPrototypeOf(normalizedMethodRecords,null)
672+
648673
module.exports={
649674
kEnumerableProperty,
650675
nop,
@@ -683,6 +708,8 @@ module.exports = {
683708
isValidHeaderValue,
684709
isTokenCharCode,
685710
parseRangeHeader,
711+
normalizedMethodRecordsBase,
712+
normalizedMethodRecords,
686713
isValidPort,
687714
isHttpOrHttpsPrefixed,
688715
nodeMajor,

‎deps/undici/src/lib/dispatcher/client-h1.js‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -978,27 +978,27 @@ function writeH1 (client, request) {
978978

979979
/* istanbul ignore else: assertion */
980980
if(!body||bodyLength===0){
981-
writeBuffer({abort,body: null, client, request, socket, contentLength, header, expectsPayload})
981+
writeBuffer(abort,null,client,request,socket,contentLength,header,expectsPayload)
982982
}elseif(util.isBuffer(body)){
983-
writeBuffer({abort, body, client, request, socket, contentLength, header, expectsPayload})
983+
writeBuffer(abort,body,client,request,socket,contentLength,header,expectsPayload)
984984
}elseif(util.isBlobLike(body)){
985985
if(typeofbody.stream==='function'){
986-
writeIterable({abort,body: body.stream(), client, request, socket, contentLength, header, expectsPayload})
986+
writeIterable(abort,body.stream(),client,request,socket,contentLength,header,expectsPayload)
987987
}else{
988-
writeBlob({abort, body, client, request, socket, contentLength, header, expectsPayload})
988+
writeBlob(abort,body,client,request,socket,contentLength,header,expectsPayload)
989989
}
990990
}elseif(util.isStream(body)){
991-
writeStream({abort, body, client, request, socket, contentLength, header, expectsPayload})
991+
writeStream(abort,body,client,request,socket,contentLength,header,expectsPayload)
992992
}elseif(util.isIterable(body)){
993-
writeIterable({abort, body, client, request, socket, contentLength, header, expectsPayload})
993+
writeIterable(abort,body,client,request,socket,contentLength,header,expectsPayload)
994994
}else{
995995
assert(false)
996996
}
997997

998998
returntrue
999999
}
10001000

1001-
functionwriteStream({abort, body, client, request, socket, contentLength, header, expectsPayload}){
1001+
functionwriteStream(abort,body,client,request,socket,contentLength,header,expectsPayload){
10021002
assert(contentLength!==0||client[kRunning]===0,'stream body cannot be pipelined')
10031003

10041004
letfinished=false
@@ -1101,7 +1101,7 @@ function writeStream ({ abort, body, client, request, socket, contentLength, hea
11011101
}
11021102
}
11031103

1104-
functionwriteBuffer({abort, body, client, request, socket, contentLength, header, expectsPayload}){
1104+
functionwriteBuffer(abort,body,client,request,socket,contentLength,header,expectsPayload){
11051105
try{
11061106
if(!body){
11071107
if(contentLength===0){
@@ -1131,7 +1131,7 @@ function writeBuffer ({ abort, body, client, request, socket, contentLength, hea
11311131
}
11321132
}
11331133

1134-
asyncfunctionwriteBlob({abort, body, client, request, socket, contentLength, header, expectsPayload}){
1134+
asyncfunctionwriteBlob(abort,body,client,request,socket,contentLength,header,expectsPayload){
11351135
assert(contentLength===body.size,'blob body must have content length')
11361136

11371137
try{
@@ -1159,7 +1159,7 @@ async function writeBlob ({ abort, body, client, request, socket, contentLength,
11591159
}
11601160
}
11611161

1162-
asyncfunctionwriteIterable({abort, body, client, request, socket, contentLength, header, expectsPayload}){
1162+
asyncfunctionwriteIterable(abort,body,client,request,socket,contentLength,header,expectsPayload){
11631163
assert(contentLength!==0||client[kRunning]===0,'iterator body cannot be pipelined')
11641164

11651165
letcallback=null

‎deps/undici/src/lib/dispatcher/client-h2.js‎

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -477,82 +477,80 @@ function writeH2 (client, request) {
477477
functionwriteBodyH2(){
478478
/* istanbul ignore else: assertion */
479479
if(!body||contentLength===0){
480-
writeBuffer({
480+
writeBuffer(
481481
abort,
482+
stream,
483+
null,
482484
client,
483485
request,
486+
client[kSocket],
484487
contentLength,
485-
expectsPayload,
486-
h2stream: stream,
487-
body: null,
488-
socket: client[kSocket]
489-
})
488+
expectsPayload
489+
)
490490
}elseif(util.isBuffer(body)){
491-
writeBuffer({
491+
writeBuffer(
492492
abort,
493+
stream,
494+
body,
493495
client,
494496
request,
497+
client[kSocket],
495498
contentLength,
496-
body,
497-
expectsPayload,
498-
h2stream: stream,
499-
socket: client[kSocket]
500-
})
499+
expectsPayload
500+
)
501501
}elseif(util.isBlobLike(body)){
502502
if(typeofbody.stream==='function'){
503-
writeIterable({
503+
writeIterable(
504504
abort,
505+
stream,
506+
body.stream(),
505507
client,
506508
request,
509+
client[kSocket],
507510
contentLength,
508-
expectsPayload,
509-
h2stream: stream,
510-
body: body.stream(),
511-
socket: client[kSocket]
512-
})
511+
expectsPayload
512+
)
513513
}else{
514-
writeBlob({
514+
writeBlob(
515515
abort,
516+
stream,
516517
body,
517518
client,
518519
request,
520+
client[kSocket],
519521
contentLength,
520-
expectsPayload,
521-
h2stream: stream,
522-
socket: client[kSocket]
523-
})
522+
expectsPayload
523+
)
524524
}
525525
}elseif(util.isStream(body)){
526-
writeStream({
526+
writeStream(
527527
abort,
528+
client[kSocket],
529+
expectsPayload,
530+
stream,
528531
body,
529532
client,
530533
request,
531-
contentLength,
532-
expectsPayload,
533-
socket: client[kSocket],
534-
h2stream: stream,
535-
header: ''
536-
})
534+
contentLength
535+
)
537536
}elseif(util.isIterable(body)){
538-
writeIterable({
537+
writeIterable(
539538
abort,
539+
stream,
540540
body,
541541
client,
542542
request,
543+
client[kSocket],
543544
contentLength,
544-
expectsPayload,
545-
header: '',
546-
h2stream: stream,
547-
socket: client[kSocket]
548-
})
545+
expectsPayload
546+
)
549547
}else{
550548
assert(false)
551549
}
552550
}
553551
}
554552

555-
functionwriteBuffer({abort, h2stream, body, client, request, socket, contentLength, expectsPayload}){
553+
functionwriteBuffer(abort,h2stream,body,client,request,socket,contentLength,expectsPayload){
556554
try{
557555
if(body!=null&&util.isBuffer(body)){
558556
assert(contentLength===body.byteLength,'buffer body must have content length')
@@ -575,7 +573,7 @@ function writeBuffer ({ abort, h2stream, body, client, request, socket, contentL
575573
}
576574
}
577575

578-
functionwriteStream({abort, socket, expectsPayload, h2stream, body, client, request, contentLength}){
576+
functionwriteStream(abort,socket,expectsPayload,h2stream,body,client,request,contentLength){
579577
assert(contentLength!==0||client[kRunning]===0,'stream body cannot be pipelined')
580578

581579
// For HTTP/2, is enough to pipe the stream
@@ -606,7 +604,7 @@ function writeStream ({ abort, socket, expectsPayload, h2stream, body, client, r
606604
}
607605
}
608606

609-
asyncfunctionwriteBlob({abort, h2stream, body, client, request, socket, contentLength, expectsPayload}){
607+
asyncfunctionwriteBlob(abort,h2stream,body,client,request,socket,contentLength,expectsPayload){
610608
assert(contentLength===body.size,'blob body must have content length')
611609

612610
try{
@@ -634,7 +632,7 @@ async function writeBlob ({ abort, h2stream, body, client, request, socket, cont
634632
}
635633
}
636634

637-
asyncfunctionwriteIterable({abort, h2stream, body, client, request, socket, contentLength, expectsPayload}){
635+
asyncfunctionwriteIterable(abort,h2stream,body,client,request,socket,contentLength,expectsPayload){
638636
assert(contentLength!==0||client[kRunning]===0,'iterator body cannot be pipelined')
639637

640638
letcallback=null

‎deps/undici/src/lib/handler/retry-handler.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class RetryHandler {
202202
this.abort(
203203
newRequestRetryError('Content-Range mismatch',statusCode,{
204204
headers,
205-
count: this.retryCount
205+
data: {count: this.retryCount}
206206
})
207207
)
208208
returnfalse
@@ -213,7 +213,7 @@ class RetryHandler {
213213
this.abort(
214214
newRequestRetryError('ETag mismatch',statusCode,{
215215
headers,
216-
count: this.retryCount
216+
data: {count: this.retryCount}
217217
})
218218
)
219219
returnfalse

‎deps/undici/src/lib/web/fetch/request.js‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ const nodeUtil = require('node:util')
1010
const{
1111
isValidHTTPToken,
1212
sameOrigin,
13-
normalizeMethod,
14-
environmentSettingsObject,
15-
normalizeMethodRecord
13+
environmentSettingsObject
1614
}=require('./util')
1715
const{
1816
forbiddenMethodsSet,
@@ -24,7 +22,7 @@ const {
2422
requestCache,
2523
requestDuplex
2624
}=require('./constants')
27-
const{ kEnumerableProperty }=util
25+
const{ kEnumerableProperty, normalizedMethodRecordsBase, normalizedMethodRecords}=util
2826
const{ kHeaders, kSignal, kState, kDispatcher }=require('./symbols')
2927
const{ webidl }=require('./webidl')
3028
const{ URLSerializer }=require('./data-url')
@@ -349,7 +347,7 @@ class Request {
349347
// 1. Let method be init["method"].
350348
letmethod=init.method
351349

352-
constmayBeNormalized=normalizeMethodRecord[method]
350+
constmayBeNormalized=normalizedMethodRecords[method]
353351

354352
if(mayBeNormalized!==undefined){
355353
// Note: Bypass validation DELETE, GET, HEAD, OPTIONS, POST, PUT, PATCH and these lowercase ones
@@ -361,12 +359,16 @@ class Request {
361359
thrownewTypeError(`'${method}' is not a valid HTTP method.`)
362360
}
363361

364-
if(forbiddenMethodsSet.has(method.toUpperCase())){
362+
constupperCase=method.toUpperCase()
363+
364+
if(forbiddenMethodsSet.has(upperCase)){
365365
thrownewTypeError(`'${method}' HTTP method is unsupported.`)
366366
}
367367

368368
// 3. Normalize method.
369-
method=normalizeMethod(method)
369+
// https://fetch.spec.whatwg.org/#concept-method-normalize
370+
// Note: must be in uppercase
371+
method=normalizedMethodRecordsBase[upperCase]??method
370372

371373
// 4. Set request’s method to method.
372374
request.method=method

0 commit comments

Comments
 (0)