Skip to content

Commit cdd7bbc

Browse files
committed
deps: undici@6.26.0
1 parent fde87c9 commit cdd7bbc

4 files changed

Lines changed: 72 additions & 27 deletions

File tree

node_modules/undici/lib/dispatcher/agent.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ function defaultFactory (origin, opts) {
2424

2525
class Agent extends DispatcherBase {
2626
constructor ({ factory = defaultFactory, maxRedirections = 0, connect, ...options } = {}) {
27-
2827
if (typeof factory !== 'function') {
2928
throw new InvalidArgumentError('factory must be a function.')
3029
}

node_modules/undici/lib/dispatcher/client-h1.js

Lines changed: 68 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -279,29 +279,71 @@ class Parser {
279279

280280
const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr
281281

282-
if (ret === constants.ERROR.PAUSED_UPGRADE) {
283-
this.onUpgrade(data.slice(offset))
284-
} else if (ret === constants.ERROR.PAUSED) {
285-
this.paused = true
286-
socket.unshift(data.slice(offset))
287-
} else if (ret !== constants.ERROR.OK) {
288-
const ptr = llhttp.llhttp_get_error_reason(this.ptr)
289-
let message = ''
290-
/* istanbul ignore else: difficult to make a test case for */
291-
if (ptr) {
292-
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
293-
message =
294-
'Response does not match the HTTP/1.1 protocol (' +
295-
Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
296-
')'
282+
if (ret !== constants.ERROR.OK) {
283+
const body = data.subarray(offset)
284+
285+
if (ret === constants.ERROR.PAUSED_UPGRADE) {
286+
this.onUpgrade(body)
287+
} else if (ret === constants.ERROR.PAUSED) {
288+
this.paused = true
289+
socket.unshift(body)
290+
} else {
291+
throw this.createError(ret, body)
297292
}
298-
throw new HTTPParserError(message, constants.ERROR[ret], data.slice(offset))
299293
}
300294
} catch (err) {
301295
util.destroy(socket, err)
302296
}
303297
}
304298

299+
finish () {
300+
assert(currentParser === null)
301+
assert(this.ptr != null)
302+
assert(!this.paused)
303+
304+
const { llhttp } = this
305+
306+
let ret
307+
308+
try {
309+
currentParser = this
310+
ret = llhttp.llhttp_finish(this.ptr)
311+
} finally {
312+
currentParser = null
313+
}
314+
315+
if (ret === constants.ERROR.OK) {
316+
return null
317+
}
318+
319+
if (ret === constants.ERROR.PAUSED || ret === constants.ERROR.PAUSED_UPGRADE) {
320+
this.paused = true
321+
return null
322+
}
323+
324+
return this.createError(ret, EMPTY_BUF)
325+
}
326+
327+
createError (ret, data) {
328+
const { llhttp, contentLength, bytesRead } = this
329+
330+
if (contentLength && bytesRead !== parseInt(contentLength, 10)) {
331+
return new ResponseContentLengthMismatchError()
332+
}
333+
334+
const ptr = llhttp.llhttp_get_error_reason(this.ptr)
335+
let message = ''
336+
if (ptr) {
337+
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
338+
message =
339+
'Response does not match the HTTP/1.1 protocol (' +
340+
Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
341+
')'
342+
}
343+
344+
return new HTTPParserError(message, constants.ERROR[ret], data)
345+
}
346+
305347
destroy () {
306348
assert(this.ptr != null)
307349
assert(currentParser == null)
@@ -673,8 +715,11 @@ async function connectH1 (client, socket) {
673715
// On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded
674716
// to the user.
675717
if (err.code === 'ECONNRESET' && parser.statusCode && !parser.shouldKeepAlive) {
676-
// We treat all incoming data so for as a valid response.
677-
parser.onMessageComplete()
718+
const parserErr = parser.finish()
719+
if (parserErr) {
720+
this[kError] = parserErr
721+
this[kClient][kOnError](parserErr)
722+
}
678723
return
679724
}
680725

@@ -693,8 +738,10 @@ async function connectH1 (client, socket) {
693738
const parser = this[kParser]
694739

695740
if (parser.statusCode && !parser.shouldKeepAlive) {
696-
// We treat all incoming data so far as a valid response.
697-
parser.onMessageComplete()
741+
const parserErr = parser.finish()
742+
if (parserErr) {
743+
util.destroy(this, parserErr)
744+
}
698745
return
699746
}
700747

@@ -706,8 +753,7 @@ async function connectH1 (client, socket) {
706753

707754
if (parser) {
708755
if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) {
709-
// We treat all incoming data so far as a valid response.
710-
parser.onMessageComplete()
756+
this[kError] = parser.finish() || this[kError]
711757
}
712758

713759
this[kParser].destroy()

node_modules/undici/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": "6.25.0",
3+
"version": "6.26.0",
44
"description": "An HTTP/1.1 client, written from scratch for Node.js",
55
"homepage": "https://undici.nodejs.org",
66
"bugs": {

package-lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13997,9 +13997,9 @@
1399713997
}
1399813998
},
1399913999
"node_modules/undici": {
14000-
"version": "6.25.0",
14001-
"resolved": "https://registry.npmjs.org/undici/-/undici-6.25.0.tgz",
14002-
"integrity": "sha512-ZgpWDC5gmNiuY9CnLVXEH8rl50xhRCuLNA97fAUnKi8RRuV4E6KG31pDTsLVUKnohJE0I3XDrTeEydAXRw47xg==",
14000+
"version": "6.26.0",
14001+
"resolved": "https://registry.npmjs.org/undici/-/undici-6.26.0.tgz",
14002+
"integrity": "sha512-4yqz8a3n5HmGTlsbADNtr/dJlhkh/55Rq798G6ibiULcXbDtaLpTl1pvdqcbFfeoj3iSi52lePFM7h9H21cw/A==",
1400314003
"inBundle": true,
1400414004
"license": "MIT",
1400514005
"engines": {

0 commit comments

Comments
 (0)