@smithy/node-http-handler
Advanced tools
+44
-37
@@ -5,6 +5,5 @@ 'use strict'; | ||
| var querystringBuilder = require('@smithy/querystring-builder'); | ||
| var http = require('http'); | ||
| var https = require('https'); | ||
| var stream = require('stream'); | ||
| var http2 = require('http2'); | ||
| var node_https = require('node:https'); | ||
| var node_stream = require('node:stream'); | ||
| var http2 = require('node:http2'); | ||
@@ -181,3 +180,3 @@ function buildAbortError(abortSignal) { | ||
| function writeBody(httpRequest, body) { | ||
| if (body instanceof stream.Readable) { | ||
| if (body instanceof node_stream.Readable) { | ||
| body.pipe(httpRequest); | ||
@@ -213,2 +212,4 @@ return; | ||
| const DEFAULT_REQUEST_TIMEOUT = 0; | ||
| let hAgent = undefined; | ||
| let hRequest = undefined; | ||
| class NodeHttpHandler { | ||
@@ -263,29 +264,2 @@ config; | ||
| } | ||
| resolveDefaultConfig(options) { | ||
| const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger, } = options || {}; | ||
| const keepAlive = true; | ||
| const maxSockets = 50; | ||
| return { | ||
| connectionTimeout, | ||
| requestTimeout, | ||
| socketTimeout, | ||
| socketAcquisitionWarningTimeout, | ||
| throwOnRequestTimeout, | ||
| httpAgent: (() => { | ||
| if (httpAgent instanceof http.Agent || typeof httpAgent?.destroy === "function") { | ||
| this.externalAgent = true; | ||
| return httpAgent; | ||
| } | ||
| return new http.Agent({ keepAlive, maxSockets, ...httpAgent }); | ||
| })(), | ||
| httpsAgent: (() => { | ||
| if (httpsAgent instanceof https.Agent || typeof httpsAgent?.destroy === "function") { | ||
| this.externalAgent = true; | ||
| return httpsAgent; | ||
| } | ||
| return new https.Agent({ keepAlive, maxSockets, ...httpsAgent }); | ||
| })(), | ||
| logger, | ||
| }; | ||
| } | ||
| destroy() { | ||
@@ -299,4 +273,8 @@ this.config?.httpAgent?.destroy(); | ||
| } | ||
| const config = this.config; | ||
| const isSSL = request.protocol === "https:"; | ||
| if (!isSSL && !this.config.httpAgent) { | ||
| this.config.httpAgent = await this.config.httpAgentProvider(); | ||
| } | ||
| return new Promise((_resolve, _reject) => { | ||
| const config = this.config; | ||
| let writeRequestBodyPromise = undefined; | ||
@@ -319,3 +297,2 @@ const timeouts = []; | ||
| } | ||
| const isSSL = request.protocol === "https:"; | ||
| const headers = request.headers ?? {}; | ||
@@ -325,3 +302,3 @@ const expectContinue = (headers.Expect ?? headers.expect) === "100-continue"; | ||
| if (expectContinue && !this.externalAgent) { | ||
| agent = new (isSSL ? https.Agent : http.Agent)({ | ||
| agent = new (isSSL ? node_https.Agent : hAgent)({ | ||
| keepAlive: false, | ||
@@ -364,3 +341,3 @@ maxSockets: Infinity, | ||
| }; | ||
| const requestFunc = isSSL ? https.request : http.request; | ||
| const requestFunc = isSSL ? node_https.request : hRequest; | ||
| const req = requestFunc(nodeHttpsOptions, (res) => { | ||
@@ -427,2 +404,32 @@ const httpResponse = new protocolHttp.HttpResponse({ | ||
| } | ||
| resolveDefaultConfig(options) { | ||
| const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger, } = options || {}; | ||
| const keepAlive = true; | ||
| const maxSockets = 50; | ||
| return { | ||
| connectionTimeout, | ||
| requestTimeout, | ||
| socketTimeout, | ||
| socketAcquisitionWarningTimeout, | ||
| throwOnRequestTimeout, | ||
| httpAgentProvider: async () => { | ||
| const { Agent, request } = await import('node:http'); | ||
| hRequest = request; | ||
| hAgent = Agent; | ||
| if (httpAgent instanceof hAgent || typeof httpAgent?.destroy === "function") { | ||
| this.externalAgent = true; | ||
| return httpAgent; | ||
| } | ||
| return new hAgent({ keepAlive, maxSockets, ...httpAgent }); | ||
| }, | ||
| httpsAgent: (() => { | ||
| if (httpsAgent instanceof node_https.Agent || typeof httpsAgent?.destroy === "function") { | ||
| this.externalAgent = true; | ||
| return httpsAgent; | ||
| } | ||
| return new node_https.Agent({ keepAlive, maxSockets, ...httpsAgent }); | ||
| })(), | ||
| logger, | ||
| }; | ||
| } | ||
| } | ||
@@ -712,3 +719,3 @@ | ||
| class Collector extends stream.Writable { | ||
| class Collector extends node_stream.Writable { | ||
| bufferedBytes = []; | ||
@@ -715,0 +722,0 @@ _write(chunk, encoding, callback) { |
| import { HttpResponse } from "@smithy/protocol-http"; | ||
| import { buildQueryString } from "@smithy/querystring-builder"; | ||
| import { Agent as hAgent, request as hRequest } from "http"; | ||
| import { Agent as hsAgent, request as hsRequest } from "https"; | ||
| import { Agent as hsAgent, request as hsRequest } from "node:https"; | ||
| import { buildAbortError } from "./build-abort-error"; | ||
@@ -15,2 +14,4 @@ import { NODEJS_TIMEOUT_ERROR_CODES } from "./constants"; | ||
| export const DEFAULT_REQUEST_TIMEOUT = 0; | ||
| let hAgent = undefined; | ||
| let hRequest = undefined; | ||
| export class NodeHttpHandler { | ||
@@ -65,29 +66,2 @@ config; | ||
| } | ||
| resolveDefaultConfig(options) { | ||
| const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger, } = options || {}; | ||
| const keepAlive = true; | ||
| const maxSockets = 50; | ||
| return { | ||
| connectionTimeout, | ||
| requestTimeout, | ||
| socketTimeout, | ||
| socketAcquisitionWarningTimeout, | ||
| throwOnRequestTimeout, | ||
| httpAgent: (() => { | ||
| if (httpAgent instanceof hAgent || typeof httpAgent?.destroy === "function") { | ||
| this.externalAgent = true; | ||
| return httpAgent; | ||
| } | ||
| return new hAgent({ keepAlive, maxSockets, ...httpAgent }); | ||
| })(), | ||
| httpsAgent: (() => { | ||
| if (httpsAgent instanceof hsAgent || typeof httpsAgent?.destroy === "function") { | ||
| this.externalAgent = true; | ||
| return httpsAgent; | ||
| } | ||
| return new hsAgent({ keepAlive, maxSockets, ...httpsAgent }); | ||
| })(), | ||
| logger, | ||
| }; | ||
| } | ||
| destroy() { | ||
@@ -101,4 +75,8 @@ this.config?.httpAgent?.destroy(); | ||
| } | ||
| const config = this.config; | ||
| const isSSL = request.protocol === "https:"; | ||
| if (!isSSL && !this.config.httpAgent) { | ||
| this.config.httpAgent = await this.config.httpAgentProvider(); | ||
| } | ||
| return new Promise((_resolve, _reject) => { | ||
| const config = this.config; | ||
| let writeRequestBodyPromise = undefined; | ||
@@ -121,3 +99,2 @@ const timeouts = []; | ||
| } | ||
| const isSSL = request.protocol === "https:"; | ||
| const headers = request.headers ?? {}; | ||
@@ -227,2 +204,32 @@ const expectContinue = (headers.Expect ?? headers.expect) === "100-continue"; | ||
| } | ||
| resolveDefaultConfig(options) { | ||
| const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger, } = options || {}; | ||
| const keepAlive = true; | ||
| const maxSockets = 50; | ||
| return { | ||
| connectionTimeout, | ||
| requestTimeout, | ||
| socketTimeout, | ||
| socketAcquisitionWarningTimeout, | ||
| throwOnRequestTimeout, | ||
| httpAgentProvider: async () => { | ||
| const { Agent, request } = await import("node:http"); | ||
| hRequest = request; | ||
| hAgent = Agent; | ||
| if (httpAgent instanceof hAgent || typeof httpAgent?.destroy === "function") { | ||
| this.externalAgent = true; | ||
| return httpAgent; | ||
| } | ||
| return new hAgent({ keepAlive, maxSockets, ...httpAgent }); | ||
| }, | ||
| httpsAgent: (() => { | ||
| if (httpsAgent instanceof hsAgent || typeof httpsAgent?.destroy === "function") { | ||
| this.externalAgent = true; | ||
| return httpsAgent; | ||
| } | ||
| return new hsAgent({ keepAlive, maxSockets, ...httpsAgent }); | ||
| })(), | ||
| logger, | ||
| }; | ||
| } | ||
| } |
@@ -1,2 +0,2 @@ | ||
| import http2 from "http2"; | ||
| import http2 from "node:http2"; | ||
| import { NodeHttp2ConnectionPool } from "./node-http2-connection-pool"; | ||
@@ -3,0 +3,0 @@ export class NodeHttp2ConnectionManager { |
| import { HttpResponse } from "@smithy/protocol-http"; | ||
| import { buildQueryString } from "@smithy/querystring-builder"; | ||
| import { constants } from "http2"; | ||
| import { constants } from "node:http2"; | ||
| import { buildAbortError } from "./build-abort-error"; | ||
@@ -5,0 +5,0 @@ import { getTransformedHeaders } from "./get-transformed-headers"; |
@@ -1,2 +0,2 @@ | ||
| import { Readable } from "stream"; | ||
| import { Readable } from "node:stream"; | ||
| export class ReadFromBuffers extends Readable { | ||
@@ -3,0 +3,0 @@ buffersToRead; |
@@ -1,7 +0,7 @@ | ||
| import { readFileSync } from "fs"; | ||
| import { createServer as createHttpServer } from "http"; | ||
| import { createServer as createHttp2Server } from "http2"; | ||
| import { createServer as createHttpsServer } from "https"; | ||
| import { join } from "path"; | ||
| import { Readable } from "stream"; | ||
| import { readFileSync } from "node:fs"; | ||
| import { createServer as createHttpServer } from "node:http"; | ||
| import { createServer as createHttp2Server } from "node:http2"; | ||
| import { createServer as createHttpsServer } from "node:https"; | ||
| import { join } from "node:path"; | ||
| import { Readable } from "node:stream"; | ||
| import { timing } from "./timing"; | ||
@@ -8,0 +8,0 @@ const fixturesDir = join(__dirname, "..", "fixtures"); |
@@ -1,2 +0,2 @@ | ||
| import { Writable } from "stream"; | ||
| import { Writable } from "node:stream"; | ||
| export class Collector extends Writable { | ||
@@ -3,0 +3,0 @@ bufferedBytes = []; |
@@ -1,2 +0,2 @@ | ||
| import { Readable } from "stream"; | ||
| import { Readable } from "node:stream"; | ||
| export class ReadFromBuffers extends Readable { | ||
@@ -3,0 +3,0 @@ buffersToRead; |
@@ -1,2 +0,2 @@ | ||
| import { Readable } from "stream"; | ||
| import { Readable } from "node:stream"; | ||
| import { timing } from "./timing"; | ||
@@ -3,0 +3,0 @@ const MIN_WAIT_TIME = 6_000; |
| import type { HeaderBag } from "@smithy/types"; | ||
| import type { IncomingHttpHeaders } from "http2"; | ||
| import type { IncomingHttpHeaders } from "node:http2"; | ||
| declare const getTransformedHeaders: (headers: IncomingHttpHeaders) => HeaderBag; | ||
| export { getTransformedHeaders }; |
| import type { HttpHandler, HttpRequest } from "@smithy/protocol-http"; | ||
| import { HttpResponse } from "@smithy/protocol-http"; | ||
| import type { HttpHandlerOptions, Logger, NodeHttpHandlerOptions, Provider } from "@smithy/types"; | ||
| import { Agent as hAgent } from "http"; | ||
| import { Agent as hsAgent } from "https"; | ||
| import type { Agent as hAgentType } from "node:http"; | ||
| import { Agent as hsAgent } from "node:https"; | ||
| export { NodeHttpHandlerOptions }; | ||
@@ -37,5 +37,4 @@ /** | ||
| */ | ||
| static checkSocketUsage(agent: hAgent | hsAgent, socketWarningTimestamp: number, logger?: Logger): number; | ||
| static checkSocketUsage(agent: hAgentType | hsAgent, socketWarningTimestamp: number, logger?: Logger): number; | ||
| constructor(options?: NodeHttpHandlerOptions | Provider<NodeHttpHandlerOptions | void>); | ||
| private resolveDefaultConfig; | ||
| destroy(): void; | ||
@@ -47,2 +46,3 @@ handle(request: HttpRequest, { abortSignal, requestTimeout }?: HttpHandlerOptions): Promise<{ | ||
| httpHandlerConfigs(): NodeHttpHandlerOptions; | ||
| private resolveDefaultConfig; | ||
| } |
| import type { RequestContext } from "@smithy/types"; | ||
| import type { ConnectConfiguration } from "@smithy/types"; | ||
| import type { ConnectionManager, ConnectionManagerConfiguration } from "@smithy/types"; | ||
| import type { ClientHttp2Session } from "http2"; | ||
| import type { ClientHttp2Session } from "node:http2"; | ||
| /** | ||
@@ -6,0 +6,0 @@ * @public |
| import type { ConnectionPool } from "@smithy/types"; | ||
| import type { ClientHttp2Session } from "http2"; | ||
| import type { ClientHttp2Session } from "node:http2"; | ||
| export declare class NodeHttp2ConnectionPool implements ConnectionPool<ClientHttp2Session> { | ||
@@ -4,0 +4,0 @@ private sessions; |
@@ -1,3 +0,3 @@ | ||
| import type { ReadableOptions } from "stream"; | ||
| import { Readable } from "stream"; | ||
| import type { ReadableOptions } from "node:stream"; | ||
| import { Readable } from "node:stream"; | ||
| export interface ReadFromBuffersOptions extends ReadableOptions { | ||
@@ -4,0 +4,0 @@ buffers: Buffer[]; |
| import type { HttpResponse } from "@smithy/types"; | ||
| import type { IncomingMessage, Server as HttpServer, ServerResponse } from "http"; | ||
| import type { Http2Server } from "http2"; | ||
| import type { Server as HttpsServer } from "https"; | ||
| import type { IncomingMessage, Server as HttpServer, ServerResponse } from "node:http"; | ||
| import type { Http2Server } from "node:http2"; | ||
| import type { Server as HttpsServer } from "node:https"; | ||
| export declare const createResponseFunction: (httpResp: HttpResponse) => (request: IncomingMessage, response: ServerResponse) => void; | ||
@@ -6,0 +6,0 @@ export declare const createResponseFunctionWithDelay: (httpResp: HttpResponse, delay: number) => (request: IncomingMessage, response: ServerResponse) => void; |
@@ -1,2 +0,2 @@ | ||
| import type { ClientRequest } from "http"; | ||
| import type { ClientRequest } from "node:http"; | ||
| export declare const setConnectionTimeout: (request: ClientRequest, reject: (err: Error) => void, timeoutInMs?: number) => NodeJS.Timeout | number; |
| import type { Logger } from "@smithy/types"; | ||
| import type { ClientRequest } from "http"; | ||
| import type { ClientRequest } from "node:http"; | ||
| /** | ||
@@ -4,0 +4,0 @@ * @internal |
@@ -1,2 +0,2 @@ | ||
| import type { ClientRequest } from "http"; | ||
| import type { ClientRequest } from "node:http"; | ||
| export interface SocketKeepAliveOptions { | ||
@@ -3,0 +3,0 @@ keepAlive: boolean; |
@@ -1,2 +0,2 @@ | ||
| import type { ClientRequest } from "http"; | ||
| import type { ClientRequest } from "node:http"; | ||
| export declare const setSocketTimeout: (request: ClientRequest, reject: (err: Error) => void, timeoutInMs?: number) => NodeJS.Timeout | number; |
@@ -1,2 +0,2 @@ | ||
| import { Writable } from "stream"; | ||
| import { Writable } from "node:stream"; | ||
| export declare class Collector extends Writable { | ||
@@ -3,0 +3,0 @@ readonly bufferedBytes: Buffer[]; |
@@ -1,3 +0,3 @@ | ||
| import type { ReadableOptions } from "stream"; | ||
| import { Readable } from "stream"; | ||
| import type { ReadableOptions } from "node:stream"; | ||
| import { Readable } from "node:stream"; | ||
| export interface ReadFromBuffersOptions extends ReadableOptions { | ||
@@ -4,0 +4,0 @@ buffers: Buffer[]; |
| import { HeaderBag } from "@smithy/types"; | ||
| import { IncomingHttpHeaders } from "http2"; | ||
| import { IncomingHttpHeaders } from "node:http2"; | ||
| declare const getTransformedHeaders: (headers: IncomingHttpHeaders) => HeaderBag; | ||
| export { getTransformedHeaders }; |
| import { HttpHandler, HttpRequest } from "@smithy/protocol-http"; | ||
| import { HttpResponse } from "@smithy/protocol-http"; | ||
| import { HttpHandlerOptions, Logger, NodeHttpHandlerOptions, Provider } from "@smithy/types"; | ||
| import { Agent as hAgent } from "http"; | ||
| import { Agent as hsAgent } from "https"; | ||
| import { Agent as hAgentType } from "node:http"; | ||
| import { Agent as hsAgent } from "node:https"; | ||
| export { NodeHttpHandlerOptions }; | ||
@@ -37,5 +37,4 @@ /** | ||
| */ | ||
| static checkSocketUsage(agent: hAgent | hsAgent, socketWarningTimestamp: number, logger?: Logger): number; | ||
| static checkSocketUsage(agent: hAgentType | hsAgent, socketWarningTimestamp: number, logger?: Logger): number; | ||
| constructor(options?: NodeHttpHandlerOptions | Provider<NodeHttpHandlerOptions | void>); | ||
| private resolveDefaultConfig; | ||
| destroy(): void; | ||
@@ -47,2 +46,3 @@ handle(request: HttpRequest, { abortSignal, requestTimeout }?: HttpHandlerOptions): Promise<{ | ||
| httpHandlerConfigs(): NodeHttpHandlerOptions; | ||
| private resolveDefaultConfig; | ||
| } |
| import { RequestContext } from "@smithy/types"; | ||
| import { ConnectConfiguration } from "@smithy/types"; | ||
| import { ConnectionManager, ConnectionManagerConfiguration } from "@smithy/types"; | ||
| import { ClientHttp2Session } from "http2"; | ||
| import { ClientHttp2Session } from "node:http2"; | ||
| /** | ||
@@ -6,0 +6,0 @@ * @public |
| import { ConnectionPool } from "@smithy/types"; | ||
| import { ClientHttp2Session } from "http2"; | ||
| import { ClientHttp2Session } from "node:http2"; | ||
| export declare class NodeHttp2ConnectionPool implements ConnectionPool<ClientHttp2Session> { | ||
@@ -4,0 +4,0 @@ private sessions; |
@@ -1,3 +0,3 @@ | ||
| import { ReadableOptions } from "stream"; | ||
| import { Readable } from "stream"; | ||
| import { ReadableOptions } from "node:stream"; | ||
| import { Readable } from "node:stream"; | ||
| export interface ReadFromBuffersOptions extends ReadableOptions { | ||
@@ -4,0 +4,0 @@ buffers: Buffer[]; |
| import { HttpResponse } from "@smithy/types"; | ||
| import { IncomingMessage, Server as HttpServer, ServerResponse } from "http"; | ||
| import { Http2Server } from "http2"; | ||
| import { Server as HttpsServer } from "https"; | ||
| import { IncomingMessage, Server as HttpServer, ServerResponse } from "node:http"; | ||
| import { Http2Server } from "node:http2"; | ||
| import { Server as HttpsServer } from "node:https"; | ||
| export declare const createResponseFunction: (httpResp: HttpResponse) => (request: IncomingMessage, response: ServerResponse) => void; | ||
@@ -6,0 +6,0 @@ export declare const createResponseFunctionWithDelay: (httpResp: HttpResponse, delay: number) => (request: IncomingMessage, response: ServerResponse) => void; |
@@ -1,2 +0,2 @@ | ||
| import { ClientRequest } from "http"; | ||
| import { ClientRequest } from "node:http"; | ||
| export declare const setConnectionTimeout: (request: ClientRequest, reject: (err: Error) => void, timeoutInMs?: number) => NodeJS.Timeout | number; |
| import { Logger } from "@smithy/types"; | ||
| import { ClientRequest } from "http"; | ||
| import { ClientRequest } from "node:http"; | ||
| /** | ||
@@ -4,0 +4,0 @@ * @internal |
@@ -1,2 +0,2 @@ | ||
| import { ClientRequest } from "http"; | ||
| import { ClientRequest } from "node:http"; | ||
| export interface SocketKeepAliveOptions { | ||
@@ -3,0 +3,0 @@ keepAlive: boolean; |
@@ -1,2 +0,2 @@ | ||
| import { ClientRequest } from "http"; | ||
| import { ClientRequest } from "node:http"; | ||
| export declare const setSocketTimeout: (request: ClientRequest, reject: (err: Error) => void, timeoutInMs?: number) => NodeJS.Timeout | number; |
@@ -1,2 +0,2 @@ | ||
| import { Writable } from "stream"; | ||
| import { Writable } from "node:stream"; | ||
| export declare class Collector extends Writable { | ||
@@ -3,0 +3,0 @@ readonly bufferedBytes: Buffer[]; |
@@ -1,3 +0,3 @@ | ||
| import { ReadableOptions } from "stream"; | ||
| import { Readable } from "stream"; | ||
| import { ReadableOptions } from "node:stream"; | ||
| import { Readable } from "node:stream"; | ||
| export interface ReadFromBuffersOptions extends ReadableOptions { | ||
@@ -4,0 +4,0 @@ buffers: Buffer[]; |
| import { HttpRequest } from "@smithy/types"; | ||
| import { ClientRequest } from "http"; | ||
| import { ClientHttp2Stream } from "http2"; | ||
| import { ClientRequest } from "node:http"; | ||
| import { ClientHttp2Stream } from "node:http2"; | ||
| /** | ||
@@ -5,0 +5,0 @@ * This resolves when writeBody has been called. |
| import type { HttpRequest } from "@smithy/types"; | ||
| import type { ClientRequest } from "http"; | ||
| import type { ClientHttp2Stream } from "http2"; | ||
| import type { ClientRequest } from "node:http"; | ||
| import type { ClientHttp2Stream } from "node:http2"; | ||
| /** | ||
@@ -5,0 +5,0 @@ * This resolves when writeBody has been called. |
+1
-1
| { | ||
| "name": "@smithy/node-http-handler", | ||
| "version": "4.4.16", | ||
| "version": "4.5.0", | ||
| "description": "Provides a way to make requests", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
100626
0.87%2147
0.66%1
-50%0
-100%