@smithy/node-http-handler
Advanced tools
Comparing version 3.2.5 to 3.3.0
@@ -59,2 +59,8 @@ var __create = Object.create; | ||
// src/timing.ts | ||
var timing = { | ||
setTimeout, | ||
clearTimeout | ||
}; | ||
// src/set-connection-timeout.ts | ||
@@ -67,3 +73,3 @@ var DEFER_EVENT_LISTENER_TIME = 1e3; | ||
const registerTimeout = /* @__PURE__ */ __name((offset) => { | ||
const timeoutId = setTimeout(() => { | ||
const timeoutId = timing.setTimeout(() => { | ||
request.destroy(); | ||
@@ -79,6 +85,6 @@ reject( | ||
socket.on("connect", () => { | ||
clearTimeout(timeoutId); | ||
timing.clearTimeout(timeoutId); | ||
}); | ||
} else { | ||
clearTimeout(timeoutId); | ||
timing.clearTimeout(timeoutId); | ||
} | ||
@@ -96,3 +102,3 @@ }, "doWithSocket"); | ||
} | ||
return setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME); | ||
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME); | ||
}, "setConnectionTimeout"); | ||
@@ -119,3 +125,3 @@ | ||
} | ||
return setTimeout(registerListener, deferTimeMs); | ||
return timing.setTimeout(registerListener, deferTimeMs); | ||
}, "setSocketKeepAlive"); | ||
@@ -136,3 +142,3 @@ | ||
} | ||
return setTimeout( | ||
return timing.setTimeout( | ||
registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME3), | ||
@@ -154,7 +160,7 @@ DEFER_EVENT_LISTENER_TIME3 | ||
new Promise((resolve) => { | ||
timeoutId = Number(setTimeout(resolve, Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs))); | ||
timeoutId = Number(timing.setTimeout(resolve, Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs))); | ||
}), | ||
new Promise((resolve) => { | ||
httpRequest.on("continue", () => { | ||
clearTimeout(timeoutId); | ||
timing.clearTimeout(timeoutId); | ||
resolve(); | ||
@@ -164,3 +170,3 @@ }); | ||
hasError = true; | ||
clearTimeout(timeoutId); | ||
timing.clearTimeout(timeoutId); | ||
resolve(); | ||
@@ -296,3 +302,3 @@ }); | ||
await writeRequestBodyPromise; | ||
timeouts.forEach(clearTimeout); | ||
timeouts.forEach(timing.clearTimeout); | ||
_resolve(arg); | ||
@@ -302,3 +308,3 @@ }, "resolve"); | ||
await writeRequestBodyPromise; | ||
timeouts.forEach(clearTimeout); | ||
timeouts.forEach(timing.clearTimeout); | ||
_reject(arg); | ||
@@ -318,3 +324,3 @@ }, "reject"); | ||
timeouts.push( | ||
setTimeout( | ||
timing.setTimeout( | ||
() => { | ||
@@ -405,3 +411,3 @@ this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage( | ||
writeRequestBodyPromise = writeRequestBody(req, request, this.config.requestTimeout).catch((e) => { | ||
timeouts.forEach(clearTimeout); | ||
timeouts.forEach(timing.clearTimeout); | ||
return _reject(e); | ||
@@ -549,3 +555,3 @@ }); | ||
setMaxConcurrentStreams(maxConcurrentStreams) { | ||
if (this.config.maxConcurrency && this.config.maxConcurrency <= 0) { | ||
if (maxConcurrentStreams && maxConcurrentStreams <= 0) { | ||
throw new RangeError("maxConcurrentStreams must be greater than zero."); | ||
@@ -552,0 +558,0 @@ } |
@@ -10,2 +10,3 @@ import { HttpResponse } from "@smithy/protocol-http"; | ||
import { setSocketTimeout } from "./set-socket-timeout"; | ||
import { timing } from "./timing"; | ||
import { writeRequestBody } from "./write-request-body"; | ||
@@ -94,3 +95,3 @@ export const DEFAULT_REQUEST_TIMEOUT = 0; | ||
await writeRequestBodyPromise; | ||
timeouts.forEach(clearTimeout); | ||
timeouts.forEach(timing.clearTimeout); | ||
_resolve(arg); | ||
@@ -100,3 +101,3 @@ }; | ||
await writeRequestBodyPromise; | ||
timeouts.forEach(clearTimeout); | ||
timeouts.forEach(timing.clearTimeout); | ||
_reject(arg); | ||
@@ -115,3 +116,3 @@ }; | ||
const agent = isSSL ? this.config.httpsAgent : this.config.httpAgent; | ||
timeouts.push(setTimeout(() => { | ||
timeouts.push(timing.setTimeout(() => { | ||
this.socketWarningTimestamp = NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, this.config.logger); | ||
@@ -194,3 +195,3 @@ }, this.config.socketAcquisitionWarningTimeout ?? | ||
writeRequestBodyPromise = writeRequestBody(req, request, this.config.requestTimeout).catch((e) => { | ||
timeouts.forEach(clearTimeout); | ||
timeouts.forEach(timing.clearTimeout); | ||
return _reject(e); | ||
@@ -197,0 +198,0 @@ }); |
@@ -75,3 +75,3 @@ import http2 from "http2"; | ||
setMaxConcurrentStreams(maxConcurrentStreams) { | ||
if (this.config.maxConcurrency && this.config.maxConcurrency <= 0) { | ||
if (maxConcurrentStreams && maxConcurrentStreams <= 0) { | ||
throw new RangeError("maxConcurrentStreams must be greater than zero."); | ||
@@ -78,0 +78,0 @@ } |
@@ -7,2 +7,3 @@ import { readFileSync } from "fs"; | ||
import { Readable } from "stream"; | ||
import { timing } from "./timing"; | ||
const fixturesDir = join(__dirname, "..", "fixtures"); | ||
@@ -24,2 +25,5 @@ const setResponseHeaders = (response, headers) => { | ||
response.statusCode = httpResp.statusCode; | ||
if (httpResp.reason) { | ||
response.statusMessage = httpResp.reason; | ||
} | ||
setResponseHeaders(response, httpResp.headers); | ||
@@ -30,8 +34,11 @@ setResponseBody(response, httpResp.body); | ||
response.statusCode = httpResp.statusCode; | ||
if (httpResp.reason) { | ||
response.statusMessage = httpResp.reason; | ||
} | ||
setResponseHeaders(response, httpResp.headers); | ||
setTimeout(() => setResponseBody(response, httpResp.body), delay); | ||
timing.setTimeout(() => setResponseBody(response, httpResp.body), delay); | ||
}; | ||
export const createContinueResponseFunction = (httpResp) => (request, response) => { | ||
response.writeContinue(); | ||
setTimeout(() => { | ||
timing.setTimeout(() => { | ||
createResponseFunction(httpResp)(request, response); | ||
@@ -38,0 +45,0 @@ }, 100); |
@@ -0,1 +1,2 @@ | ||
import { timing } from "./timing"; | ||
const DEFER_EVENT_LISTENER_TIME = 1000; | ||
@@ -7,3 +8,3 @@ export const setConnectionTimeout = (request, reject, timeoutInMs = 0) => { | ||
const registerTimeout = (offset) => { | ||
const timeoutId = setTimeout(() => { | ||
const timeoutId = timing.setTimeout(() => { | ||
request.destroy(); | ||
@@ -17,7 +18,7 @@ reject(Object.assign(new Error(`Socket timed out without establishing a connection within ${timeoutInMs} ms`), { | ||
socket.on("connect", () => { | ||
clearTimeout(timeoutId); | ||
timing.clearTimeout(timeoutId); | ||
}); | ||
} | ||
else { | ||
clearTimeout(timeoutId); | ||
timing.clearTimeout(timeoutId); | ||
} | ||
@@ -36,3 +37,3 @@ }; | ||
} | ||
return setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME); | ||
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME); | ||
}; |
@@ -0,1 +1,2 @@ | ||
import { timing } from "./timing"; | ||
const DEFER_EVENT_LISTENER_TIME = 3000; | ||
@@ -20,3 +21,3 @@ export const setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME) => { | ||
} | ||
return setTimeout(registerListener, deferTimeMs); | ||
return timing.setTimeout(registerListener, deferTimeMs); | ||
}; |
@@ -0,1 +1,2 @@ | ||
import { timing } from "./timing"; | ||
const DEFER_EVENT_LISTENER_TIME = 3000; | ||
@@ -13,3 +14,3 @@ export const setSocketTimeout = (request, reject, timeoutInMs = 0) => { | ||
} | ||
return setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME); | ||
return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME); | ||
}; |
import { Readable } from "stream"; | ||
import { timing } from "./timing"; | ||
const MIN_WAIT_TIME = 1000; | ||
@@ -11,7 +12,7 @@ export async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME) { | ||
new Promise((resolve) => { | ||
timeoutId = Number(setTimeout(resolve, Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs))); | ||
timeoutId = Number(timing.setTimeout(resolve, Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs))); | ||
}), | ||
new Promise((resolve) => { | ||
httpRequest.on("continue", () => { | ||
clearTimeout(timeoutId); | ||
timing.clearTimeout(timeoutId); | ||
resolve(); | ||
@@ -21,3 +22,3 @@ }); | ||
hasError = true; | ||
clearTimeout(timeoutId); | ||
timing.clearTimeout(timeoutId); | ||
resolve(); | ||
@@ -24,0 +25,0 @@ }); |
{ | ||
"name": "@smithy/node-http-handler", | ||
"version": "3.2.5", | ||
"version": "3.3.0", | ||
"description": "Provides a way to make requests", | ||
@@ -16,3 +16,4 @@ "scripts": { | ||
"extract:docs": "api-extractor run --local", | ||
"test": "yarn g:jest --coverage --forceExit" | ||
"test": "yarn g:vitest run", | ||
"test:watch": "yarn g:vitest watch" | ||
}, | ||
@@ -29,6 +30,6 @@ "author": { | ||
"dependencies": { | ||
"@smithy/abort-controller": "^3.1.6", | ||
"@smithy/protocol-http": "^4.1.5", | ||
"@smithy/querystring-builder": "^3.0.8", | ||
"@smithy/types": "^3.6.0", | ||
"@smithy/abort-controller": "^3.1.7", | ||
"@smithy/protocol-http": "^4.1.6", | ||
"@smithy/querystring-builder": "^3.0.9", | ||
"@smithy/types": "^3.7.0", | ||
"tslib": "^2.6.2" | ||
@@ -35,0 +36,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94347
71
2046
50
2
4
1
25