Skip to content

Commit

Permalink
Lock file maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] authored and github-actions[bot] committed Nov 6, 2023
1 parent f8c9222 commit 48a296c
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 37 deletions.
85 changes: 60 additions & 25 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15959,23 +15959,7 @@ function _resume (client, sync) {
return
}

if (util.isStream(request.body) && util.bodyLength(request.body) === 0) {
request.body
.on('data', /* istanbul ignore next */ function () {
/* istanbul ignore next */
assert(false)
})
.on('error', function (err) {
errorRequest(client, request, err)
})
.on('end', function () {
util.destroy(this)
})

request.body = null
}

if (client[kRunning] > 0 &&
if (client[kRunning] > 0 && util.bodyLength(request.body) !== 0 &&
(util.isStream(request.body) || util.isAsyncIterable(request.body))) {
// Request with stream or iterator body can error while other requests
// are inflight and indirectly error those as well.
Expand All @@ -15996,6 +15980,11 @@ function _resume (client, sync) {
}
}

// https://www.rfc-editor.org/rfc/rfc7230#section-3.3.2
function shouldSendContentLength (method) {
return method !== 'GET' && method !== 'HEAD' && method !== 'OPTIONS' && method !== 'TRACE' && method !== 'CONNECT'
}

function write (client, request) {
if (client[kHTTPConnVersion] === 'h2') {
writeH2(client, client[kHTTP2Session], request)
Expand Down Expand Up @@ -16024,7 +16013,9 @@ function write (client, request) {
body.read(0)
}

let contentLength = util.bodyLength(body)
const bodyLength = util.bodyLength(body)

let contentLength = bodyLength

if (contentLength === null) {
contentLength = request.contentLength
Expand All @@ -16039,7 +16030,9 @@ function write (client, request) {
contentLength = null
}

if (request.contentLength !== null && request.contentLength !== contentLength) {
// https://github.com/nodejs/undici/issues/2046
// A user agent may send a Content-Length header with 0 value, this should be allowed.
if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength !== null && request.contentLength !== contentLength) {
if (client[kStrictContentLength]) {
errorRequest(client, request, new RequestContentLengthMismatchError())
return false
Expand Down Expand Up @@ -16120,7 +16113,7 @@ function write (client, request) {
}

/* istanbul ignore else: assertion */
if (!body) {
if (!body || bodyLength === 0) {
if (contentLength === 0) {
socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1')
} else {
Expand Down Expand Up @@ -16260,7 +16253,9 @@ function writeH2 (client, session, request) {
contentLength = null
}

if (request.contentLength != null && request.contentLength !== contentLength) {
// https://github.com/nodejs/undici/issues/2046
// A user agent may send a Content-Length header with 0 value, this should be allowed.
if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength != null && request.contentLength !== contentLength) {
if (client[kStrictContentLength]) {
errorRequest(client, request, new RequestContentLengthMismatchError())
return false
Expand Down Expand Up @@ -18222,10 +18217,29 @@ class Request {

this.method = method

this.abort = null

if (body == null) {
this.body = null
} else if (util.isStream(body)) {
this.body = body

const rState = this.body._readableState
if (!rState || !rState.autoDestroy) {
this.endHandler = function autoDestroy () {
util.destroy(this)
}
this.body.on('end', this.endHandler)
}

this.errorHandler = err => {
if (this.abort) {
this.abort(err)
} else {
this.error = err
}
}
this.body.on('error', this.errorHandler)
} else if (util.isBuffer(body)) {
this.body = body.byteLength ? body : null
} else if (ArrayBuffer.isView(body)) {
Expand Down Expand Up @@ -18346,7 +18360,12 @@ class Request {
assert(!this.aborted)
assert(!this.completed)

return this[kHandler].onConnect(abort)
if (this.error) {
abort(this.error)
} else {
this.abort = abort
return this[kHandler].onConnect(abort)
}
}

onHeaders (statusCode, headers, resume, statusText) {
Expand Down Expand Up @@ -18375,6 +18394,8 @@ class Request {
}

onComplete (trailers) {
this.onFinally()

assert(!this.aborted)

this.completed = true
Expand All @@ -18385,6 +18406,8 @@ class Request {
}

onError (error) {
this.onFinally()

if (channels.error.hasSubscribers) {
channels.error.publish({ request: this, error })
}
Expand All @@ -18396,6 +18419,18 @@ class Request {
return this[kHandler].onError(error)
}

onFinally () {
if (this.errorHandler) {
this.body.off('error', this.errorHandler)
this.errorHandler = null
}

if (this.endHandler) {
this.body.off('end', this.endHandler)
this.endHandler = null
}
}

// TODO: adjust to support H2
addHeader (key, value) {
processHeader(this, key, value)
Expand Down Expand Up @@ -18819,7 +18854,7 @@ function isReadableAborted (stream) {
}

function destroy (stream, err) {
if (!isStream(stream) || isDestroyed(stream)) {
if (stream == null || !isStream(stream) || isDestroyed(stream)) {
return
}

Expand Down Expand Up @@ -30690,7 +30725,7 @@ class Pool extends PoolBase {
maxCachedSessions,
allowH2,
socketPath,
timeout: connectTimeout == null ? 10e3 : connectTimeout,
timeout: connectTimeout,
...(util.nodeHasAutoSelectFamily && autoSelectFamily ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : undefined),
...connect
})
Expand Down Expand Up @@ -33021,7 +33056,7 @@ function getUserAgent() {
return navigator.userAgent;
}

if (typeof process === "object" && "version" in process) {
if (typeof process === "object" && process.version !== undefined) {
return `Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`;
}

Expand Down
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2633,8 +2633,8 @@ __metadata:
linkType: hard

"node-gyp@npm:latest":
version: 10.0.0
resolution: "node-gyp@npm:10.0.0"
version: 10.0.1
resolution: "node-gyp@npm:10.0.1"
dependencies:
env-paths: "npm:^2.2.0"
exponential-backoff: "npm:^3.1.1"
Expand All @@ -2648,7 +2648,7 @@ __metadata:
which: "npm:^4.0.0"
bin:
node-gyp: bin/node-gyp.js
checksum: 6d18c65cae4f8cc87c8ff53bfa2626f43adfda5d5fbccbfe1c94c4e115f978f6c09072546ece2cffa36aa05ef30c261976cdcaa2c8beea069771f582b2989e93
checksum: abddfff7d873312e4ed4a5fb75ce893a5c4fb69e7fcb1dfa71c28a6b92a7f1ef6b62790dffb39181b5a82728ba8f2f32d229cf8cbe66769fe02cea7db4a555aa
languageName: node
linkType: hard

Expand Down Expand Up @@ -2995,9 +2995,9 @@ __metadata:
linkType: hard

"punycode@npm:^2.1.0":
version: 2.3.0
resolution: "punycode@npm:2.3.0"
checksum: 8e6f7abdd3a6635820049e3731c623bbef3fedbf63bbc696b0d7237fdba4cefa069bc1fa62f2938b0fbae057550df7b5318f4a6bcece27f1907fc75c54160bee
version: 2.3.1
resolution: "punycode@npm:2.3.1"
checksum: 14f76a8206bc3464f794fb2e3d3cc665ae416c01893ad7a02b23766eb07159144ee612ad67af5e84fa4479ccfe67678c4feb126b0485651b302babf66f04f9e9
languageName: node
linkType: hard

Expand Down Expand Up @@ -3713,11 +3713,11 @@ __metadata:
linkType: hard

"undici@npm:^5.25.4":
version: 5.27.0
resolution: "undici@npm:5.27.0"
version: 5.27.2
resolution: "undici@npm:5.27.2"
dependencies:
"@fastify/busboy": "npm:^2.0.0"
checksum: 68a14e0981c4ccaa9e6192bb530e1d5d608cde8423bcca8ae18a6d230366b07b328d98b1ed092c53cbd751dca3067642ab5bdaffa75c3d6d6c69b98cdb4436ce
checksum: 0cb62c57edc938f242c116e41fb2a74f81ed20e7e2e554cf1ceae548520df0592385b53d444f8cf59e1e10e6b27acd153198d8a2353b3040d0a778a099aac92c
languageName: node
linkType: hard

Expand All @@ -3740,9 +3740,9 @@ __metadata:
linkType: hard

"universal-user-agent@npm:^6.0.0":
version: 6.0.0
resolution: "universal-user-agent@npm:6.0.0"
checksum: ebeb0206963666c13bcf9ebc86d0577c7daed5870c05cd34d4972ee7a43b9ef20679baf2a8c83bf1b71d899bae67243ac4982d84ddaf9ba0355ff76595819961
version: 6.0.1
resolution: "universal-user-agent@npm:6.0.1"
checksum: 5c9c46ffe19a975e11e6443640ed4c9e0ce48fcc7203325757a8414ac49940ebb0f4667f2b1fa561489d1eb22cb2d05a0f7c82ec20c5cba42e58e188fb19b187
languageName: node
linkType: hard

Expand Down

0 comments on commit 48a296c

Please sign in to comment.