🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@smithy/node-http-handler

Package Overview
Dependencies
Maintainers
2
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/node-http-handler - npm Package Compare versions

Comparing version
4.9.4
to
4.9.5
+10
dist-types/ts3.4/build-abort-error.d.ts
/**
* Builds an abort error, using the AbortSignal's reason if available.
*
* @param abortSignal - Optional AbortSignal that may contain a reason.
* @returns A new Error with name "AbortError". If the signal has a reason that's
* already an Error, the reason is set as `cause`. Otherwise creates a
* new Error with the reason as the message, or "Request aborted" if no
* reason.
*/
export declare function buildAbortError(abortSignal?: unknown): Error;
/**
* Node.js system error codes that indicate timeout.
* @deprecated use NODEJS_TIMEOUT_ERROR_CODES from @smithy/service-error-classification/constants
*/
export declare const NODEJS_TIMEOUT_ERROR_CODES: string[];
import { IncomingHttpHeaders } from "node:http2";
import { HeaderBag } from "@smithy/types";
declare const getTransformedHeaders: (headers: IncomingHttpHeaders) => HeaderBag;
export { getTransformedHeaders };
import { ClientHttp2Session } from "node:http2";
/**
* Shared access ref counter for ClientHttp2Session, where owners are
* in-flight requests.
*
* @internal
* @since 4.6.0
*/
export declare class ClientHttp2SessionRef {
readonly id: number;
/**
* Total calls to retain for this session.
*/
total: number;
/**
* Max ref count observed.
*/
max: number;
private readonly session;
private refs;
constructor(session: ClientHttp2Session);
/**
* Signal that the session is entering a request span and has an additional owning request.
* This must be called when beginning a request using the session.
*/
retain(): void;
/**
* Release reference to session, to be called when it exits request span, indicating one fewer owning request.
* When reaching zero, the session is unref'd.
* This must be called when concluding a request using the session.
*/
free(): void;
/**
* Access the session (don't call ref/unref on it).
*/
deref(): ClientHttp2Session;
/**
* Allow open refs to free on their own.
*/
close(): void;
destroy(): void;
/**
* @returns the current number of active references (in-flight requests).
*/
useCount(): number;
}
export { DEFAULT_REQUEST_TIMEOUT, NodeHttpHandler, NodeHttpHandlerOptions } from "./node-http-handler";
export { NodeHttp2Handler, NodeHttp2HandlerOptions } from "./node-http2-handler";
export { streamCollector } from "@smithy/core/serde";
import { Agent as hAgentType } from "node:http";
import { Agent as hsAgentType } from "node:https";
import { HttpResponse, HttpHandler, HttpRequest } from "@smithy/core/protocols";
import { HttpHandlerOptions, Logger, NodeHttpHandlerOptions, Provider } from "@smithy/types";
export { NodeHttpHandlerOptions };
/**
* A default of 0 means no timeout.
*
* @public
*/
export declare const DEFAULT_REQUEST_TIMEOUT = 0;
/**
* A request handler that uses the Node.js http and https modules.
*
* @public
*/
export declare class NodeHttpHandler implements HttpHandler<NodeHttpHandlerOptions> {
private config?;
private configProvider;
private socketWarningTimestamp;
private externalAgent;
readonly metadata: {
handlerProtocol: string;
};
/**
* @returns the input if it is an HttpHandler of any class,
* or instantiates a new instance of this handler.
*/
static create(instanceOrOptions?: HttpHandler<any> | NodeHttpHandlerOptions | Provider<NodeHttpHandlerOptions | void>): NodeHttpHandler | HttpHandler<any>;
/**
* @internal
*
* @param agent - http(s) agent in use by the NodeHttpHandler instance.
* @param socketWarningTimestamp - last socket usage check timestamp.
* @param logger - channel for the warning.
* @returns timestamp of last emitted warning.
*/
static checkSocketUsage(agent: hAgentType | hsAgentType, socketWarningTimestamp: number, logger?: Logger): number;
constructor(options?: NodeHttpHandlerOptions | Provider<NodeHttpHandlerOptions | void>);
destroy(): void;
handle(request: HttpRequest, { abortSignal, requestTimeout }?: HttpHandlerOptions): Promise<{
response: HttpResponse;
}>;
updateHttpClientConfig(key: keyof NodeHttpHandlerOptions, value: NodeHttpHandlerOptions[typeof key]): void;
httpHandlerConfigs(): NodeHttpHandlerOptions;
private resolveDefaultConfig;
}
import { ClientSessionOptions, SecureClientSessionOptions } from "node:http2";
import { ConnectConfiguration, ConnectionManager, ConnectionManagerConfiguration, RequestContext } from "@smithy/types";
import { ClientHttp2SessionRef } from "./http2/ClientHttp2SessionRef";
/**
* This class previously implemented the ConnectionManager<ClientHttp2Session> interface,
* but this class isn't exported from this package, except as a private property of NodeHttp2Handler.
*
* @since 4.6.0
* @internal
*/
export declare class NodeHttp2ConnectionManager implements ConnectionManager<ClientHttp2SessionRef> {
private config;
private connectOptions?;
private readonly connectionPools;
constructor(config: ConnectionManagerConfiguration);
/**
* Acquire a session for making a request.
*/
lease(requestContext: RequestContext, connectionConfiguration: ConnectConfiguration): ClientHttp2SessionRef;
/**
* Signal that a request using this session has completed.
*
* The session remains in its pool for reuse.
* This method is not called for isolated sessions.
*/
release(_requestContext: RequestContext, ref: ClientHttp2SessionRef): void;
/**
* Create an isolated session that isn't part of the connection pools.
* For use in event-streams or when concurrency is turned off.
*/
createIsolatedSession(requestContext: RequestContext, connectionConfiguration: ConnectConfiguration): ClientHttp2SessionRef;
destroy(): void;
setMaxConcurrentStreams(maxConcurrentStreams: number): void;
setDisableConcurrentStreams(disableConcurrentStreams: boolean): void;
setNodeHttp2ConnectOptions(nodeHttp2ConnectOptions: Partial<SecureClientSessionOptions | ClientSessionOptions>): void;
/**
* @internal
* @returns a snapshot of the state of all connection pools and their sessions.
*/
debug(): Record<string, any>;
private removeFromPoolAndClose;
private removeFromPoolAndCheckedDestroy;
private getPool;
private getUrlString;
private connect;
}
import { ClientHttp2Session } from "node:http2";
import { ConnectionPool } from "@smithy/types";
import { ClientHttp2SessionRef } from "./http2/ClientHttp2SessionRef";
/**
* These are keyed by URL, therefore all sessions within this class' state
* are for the same URL.
*
* Sessions remain in the pool for their entire lifetime (until destroyed or
* removed). The pool tracks capacity via each session's ref count.
*
* Interface implementation changed from ConnectionPool<ClientHttp2Session>.
* @since 4.6.0
* @internal
*/
export declare class NodeHttp2ConnectionPool implements ConnectionPool<ClientHttp2SessionRef> {
private readonly sessions;
private maxConcurrency;
constructor(sessions?: ClientHttp2Session[]);
/**
* Find a session with available capacity (refs < maxConcurrency).
* Returns undefined if all sessions are at capacity or the pool is empty.
*/
poll(): ClientHttp2SessionRef | undefined;
/**
* Add a session to the pool.
*/
offerLast(ref: ClientHttp2SessionRef): void;
remove(ref: ClientHttp2SessionRef): void;
[Symbol.iterator](): ArrayIterator<ClientHttp2SessionRef>;
setMaxConcurrency(maxConcurrency: number): void;
/**
* This is unused, but part of the interface.
* @deprecated
*/
destroy(ref: ClientHttp2SessionRef): void;
}
import { ClientSessionOptions, SecureClientSessionOptions } from "node:http2";
import { HttpResponse, HttpHandler, HttpRequest } from "@smithy/core/protocols";
import { HttpHandlerOptions, Provider } from "@smithy/types";
/**
* Represents the http2 options that can be passed to a node http2 client.
* @public
*/
export interface NodeHttp2HandlerOptions {
/**
* The maximum time in milliseconds that a stream may remain idle before it
* is closed.
*/
requestTimeout?: number;
/**
* The maximum time in milliseconds that a session or socket may remain idle
* before it is closed.
* https://nodejs.org/docs/latest-v12.x/api/http2.html#http2_http2session_and_sockets
*/
sessionTimeout?: number;
/**
* Disables processing concurrent streams on a ClientHttp2Session instance. When set
* to true, a new session instance is created for each request to a URL.
* **Default:** false.
* https://nodejs.org/api/http2.html#http2_class_clienthttp2session
*/
disableConcurrentStreams?: boolean;
/**
* Maximum number of concurrent Http2Stream instances per ClientHttp2Session. Each session
* may have up to 2^31-1 Http2Stream instances over its lifetime.
* This value must be greater than or equal to 0.
* https://nodejs.org/api/http2.html#class-http2stream
*/
maxConcurrentStreams?: number;
/**
* A set of raw options that will be passed to http2.connect.
* https://nodejs.org/api/http2.html#http2connectauthority-options-listener
*/
nodeHttp2ConnectOptions?: Partial<SecureClientSessionOptions | ClientSessionOptions>;
}
/**
* This is derived from the smithyContext object. This signals to the NodeHttp2Handler specifically
* that the connection pool should not be used to acquire a connection. The event stream should
* have its own new connection.
*
* This does not apply to WebSocket event streams, since there is no pooling.
*
* @internal
*/
type EventStreamSignal = {
isEventStream?: boolean;
};
/**
* A request handler using the node:http2 package.
* @public
*/
export declare class NodeHttp2Handler implements HttpHandler<NodeHttp2HandlerOptions> {
private config?;
private configProvider;
readonly metadata: {
handlerProtocol: string;
};
private readonly connectionManager;
/**
* @returns the input if it is an HttpHandler of any class,
* or instantiates a new instance of this handler.
*/
static create(instanceOrOptions?: HttpHandler<any> | NodeHttp2HandlerOptions | Provider<NodeHttp2HandlerOptions | void>): HttpHandler<any> | NodeHttp2Handler;
constructor(options?: NodeHttp2HandlerOptions | Provider<NodeHttp2HandlerOptions | void>);
destroy(): void;
handle(request: HttpRequest, { abortSignal, requestTimeout, isEventStream }?: HttpHandlerOptions & EventStreamSignal): Promise<{
response: HttpResponse;
}>;
updateHttpClientConfig(key: keyof NodeHttp2HandlerOptions, value: NodeHttp2HandlerOptions[typeof key]): void;
httpHandlerConfigs(): NodeHttp2HandlerOptions;
}
export {};
import node_http2 from "node:http2";
export { node_http2 };
import node_https from "node:https";
export { node_https };
import { ClientRequest } from "node:http";
export declare const setConnectionTimeout: (request: ClientRequest, reject: (err: Error) => void, timeoutInMs?: number) => NodeJS.Timeout | number;
import { ClientRequest } from "node:http";
import { Logger } from "@smithy/types";
/**
* @internal
*/
export declare const setRequestTimeout: (req: ClientRequest, reject: (err: Error) => void, timeoutInMs?: number, throwOnRequestTimeout?: boolean, logger?: Logger) => number;
import { ClientRequest } from "node:http";
export interface SocketKeepAliveOptions {
keepAlive: boolean;
keepAliveMsecs?: number;
}
export declare const setSocketKeepAlive: (request: ClientRequest, { keepAlive, keepAliveMsecs }: SocketKeepAliveOptions, deferTimeMs?: number) => NodeJS.Timeout | number;
import { ClientRequest } from "node:http";
export declare const setSocketTimeout: (request: ClientRequest, reject: (err: Error) => void, timeoutInMs?: number) => NodeJS.Timeout | number;
/**
* For test spies.
*
* @internal
*/
export declare const timing: {
setTimeout: (cb: (...ignored: any[]) => void | unknown, ms?: number) => number;
clearTimeout: (timeoutId: string | number | undefined | unknown) => void;
};
import { ClientHttp2Stream } from "node:http2";
import { ClientRequest } from "node:http";
import { HttpRequest } from "@smithy/types";
/**
* This resolves when writeBody has been called.
*
* @param httpRequest - opened Node.js request.
* @param request - container with the request body.
* @param maxContinueTimeoutMs - time to wait for the continue event.
* @param externalAgent - whether agent is owned by caller code.
*/
export declare function writeRequestBody(httpRequest: ClientRequest | ClientHttp2Stream, request: HttpRequest, maxContinueTimeoutMs?: number, externalAgent?: boolean): Promise<void>;
+4
-4
{
"name": "@smithy/node-http-handler",
"version": "4.9.4",
"version": "4.9.5",
"description": "Provides a way to make requests",

@@ -29,8 +29,8 @@ "scripts": {

"dependencies": {
"@smithy/core": "^3.29.2",
"@smithy/types": "^4.16.0",
"@smithy/core": "^3.29.3",
"@smithy/types": "^4.16.1",
"tslib": "^2.6.2"
},
"devDependencies": {
"@smithy/abort-controller": "^4.3.2",
"@smithy/abort-controller": "^4.3.3",
"@types/node": "^18.11.9",

@@ -37,0 +37,0 @@ "concurrently": "7.0.0",