Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2023-07-13 09:09:17 +00:00
parent 4fad06f438
commit 40a500c743
4168 changed files with 298222 additions and 374905 deletions

View file

@ -40,7 +40,10 @@ class InterceptedRequestRouter {
// affecting the user so we use a clone of the object.
...options,
// We use lower-case header field names throughout Nock.
headers: common.headersFieldNamesToLowerCase(options.headers || {}),
headers: common.headersFieldNamesToLowerCase(
options.headers || {},
false
),
}
this.interceptors = interceptors
@ -48,8 +51,14 @@ class InterceptedRequestRouter {
// support setting `timeout` using request `options`
// https://nodejs.org/docs/latest-v12.x/api/http.html#http_http_request_url_options_callback
if (options.timeout) {
this.socket.setTimeout(options.timeout)
// any timeout in the request options override any timeout in the agent options.
// per https://github.com/nodejs/node/pull/21204
const timeout =
options.timeout ||
(options.agent && options.agent.options && options.agent.options.timeout)
if (timeout) {
this.socket.setTimeout(timeout)
}
this.response = new IncomingMessage(this.socket)
@ -134,8 +143,11 @@ class InterceptedRequestRouter {
// from docs: When write function is called with empty string or buffer, it does nothing and waits for more input.
// However, actually implementation checks the state of finished and aborted before checking if the first arg is empty.
handleWrite(buffer, encoding, callback) {
handleWrite(...args) {
debug('request write')
let [buffer, encoding] = args
const { req } = this
if (req.finished) {
@ -153,7 +165,7 @@ class InterceptedRequestRouter {
return false
}
if (!buffer || buffer.length === 0) {
if (!buffer) {
return true
}
@ -162,6 +174,9 @@ class InterceptedRequestRouter {
}
this.requestBodyBuffers.push(buffer)
// writable.write encoding param is optional
// so if callback is present it's the last argument
const callback = args.length > 1 ? args[args.length - 1] : undefined
// can't use instanceof Function because some test runners
// run tests in vm.runInNewContext where Function is not same
// as that in the current context
@ -279,9 +294,8 @@ class InterceptedRequestRouter {
const requestBodyBuffer = Buffer.concat(this.requestBodyBuffers)
// When request body is a binary buffer we internally use in its hexadecimal
// representation.
const requestBodyIsUtf8Representable = common.isUtf8Representable(
requestBodyBuffer
)
const requestBodyIsUtf8Representable =
common.isUtf8Representable(requestBodyBuffer)
const requestBodyString = requestBodyBuffer.toString(
requestBodyIsUtf8Representable ? 'utf8' : 'hex'
)