deps: update undici to 6.28.1 · nodejs/node@2a3548e · GitHub
Skip to content

Commit 2a3548e

Browse files
mcollinajuanarbol
authored andcommitted
deps: update undici to 6.28.1
PR-URL: #65790 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 839480a commit 2a3548e

9 files changed

Lines changed: 504 additions & 257 deletions

File tree

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

Lines changed: 12 additions & 4 deletions

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

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class RetryHandler {
9090
this.end = null
9191
this.etag = null
9292
this.resume = null
93+
this.headersSent = false
9394

9495
// Handle possible onConnect duplication
9596
this.handler.onConnect(reason => {
@@ -102,6 +103,20 @@ class RetryHandler {
102103
})
103104
}
104105

106+
checkpointResponseEnd (headers, resume) {
107+
if (this.end == null && this.opts.method !== 'HEAD') {
108+
const contentLength = headers['content-length']
109+
this.end = contentLength != null ? Number(contentLength) - 1 : null
110+
111+
assert(
112+
this.end == null || Number.isFinite(this.end),
113+
'invalid content-length'
114+
)
115+
}
116+
117+
this.resume = this.end != null ? resume : null
118+
}
119+
105120
onRequestSent () {
106121
if (this.handler.onRequestSent) {
107122
this.handler.onRequestSent()
@@ -191,6 +206,8 @@ class RetryHandler {
191206

192207
if (statusCode >= 300) {
193208
if (this.retryOpts.statusCodes.includes(statusCode) === false) {
209+
this.headersSent = true
210+
this.checkpointResponseEnd(headers, resume)
194211
return this.handler.onHeaders(
195212
statusCode,
196213
rawHeaders,
@@ -259,8 +276,15 @@ class RetryHandler {
259276

260277
const { start, size, end = size - 1 } = contentRange
261278

262-
assert(this.start === start, 'content-range mismatch')
263-
assert(this.end == null || this.end === end, 'content-range mismatch')
279+
if (this.start !== start || (this.end != null && this.end !== end)) {
280+
this.abort(
281+
new RequestRetryError('Content-Range mismatch', statusCode, {
282+
headers,
283+
data: { count: this.retryCount }
284+
})
285+
)
286+
return false
287+
}
264288

265289
this.resume = resume
266290
return true
@@ -272,6 +296,7 @@ class RetryHandler {
272296
const range = parseRangeHeader(headers['content-range'])
273297

274298
if (range == null) {
299+
this.headersSent = true
275300
return this.handler.onHeaders(
276301
statusCode,
277302
rawHeaders,
@@ -310,6 +335,7 @@ class RetryHandler {
310335
)
311336

312337
this.resume = resume
338+
this.headersSent = true
313339
this.etag = headers.etag != null ? headers.etag : null
314340

315341
// Weak etags are not useful for comparison nor cache
@@ -349,7 +375,7 @@ class RetryHandler {
349375
}
350376

351377
onError (err) {
352-
if (this.aborted || isDisturbed(this.opts.body)) {
378+
if (this.aborted || isDisturbed(this.opts.body) || (this.headersSent && this.resume == null)) {
353379
return this.handler.onError(err)
354380
}
355381

‎deps/undici/src/lib/llhttp/wasm_build_env.txt‎

Lines changed: 2 additions & 2 deletions

0 commit comments

Comments
 (0)