agent-base

  • Version 6.0.2
  • Published
  • 34.6 kB
  • 1 dependency
  • MIT license

Install

npm i agent-base
yarn add agent-base
pnpm add agent-base

Overview

Turn a function into an `http.Agent` instance

Index

Functions

function createAgent

createAgent: typeof createAgent;

    Classes

    class Agent

    class Agent extends EventEmitter {}
    • Base http.Agent implementation. No pooling/keep-alive is implemented by default.

      Parameter callback

      public

    constructor

    constructor(
    callback?:
    | {
    (
    req: ClientRequest,
    opts: RequestOptions,
    fn: AgentCallbackCallback
    ): void;
    (req: ClientRequest, opts: RequestOptions): any;
    }
    | AgentOptions,
    _opts?: AgentOptions
    );

      property defaultPort

      defaultPort: number;

        property freeSockets

        freeSockets: { [key: string]: any[] };

          property maxFreeSockets

          maxFreeSockets: number;

            property maxSockets

            maxSockets: number;

              property maxTotalSockets

              maxTotalSockets: number;

                property options

                options: any;

                  property protocol

                  protocol: string;

                    property requests

                    requests: { [key: string]: any[] };

                      property sockets

                      sockets: { [key: string]: any[] };

                        property timeout

                        timeout: number;

                          method addRequest

                          addRequest: (req: ClientRequest, _opts: RequestOptions) => void;
                          • Called by node-core's "_http_client.js" module when creating a new HTTP request with this Agent instance.

                            public

                          method callback

                          callback: {
                          (req: ClientRequest, opts: RequestOptions, fn: AgentCallbackCallback): void;
                          (req: ClientRequest, opts: RequestOptions): any;
                          };

                            method destroy

                            destroy: () => void;

                              method freeSocket

                              freeSocket: (socket: any, opts: AgentOptions) => void;

                                Interfaces

                                interface AgentRequestOptions

                                interface AgentRequestOptions {}

                                  property host

                                  host?: string;

                                    property path

                                    path?: string;

                                      property port

                                      port: number;

                                        interface ClientRequest

                                        interface ClientRequest extends http.ClientRequest {}

                                          property method

                                          method: string;

                                            interface HttpRequestOptions

                                            interface HttpRequestOptions
                                            extends AgentRequestOptions,
                                            Omit<http.RequestOptions, keyof AgentRequestOptions> {}

                                              property secureEndpoint

                                              secureEndpoint: false;

                                                interface HttpsRequestOptions

                                                interface HttpsRequestOptions
                                                extends AgentRequestOptions,
                                                Omit<https.RequestOptions, keyof AgentRequestOptions> {}

                                                  property secureEndpoint

                                                  secureEndpoint: true;

                                                    Type Aliases

                                                    type AgentCallback

                                                    type AgentCallback = typeof Agent.prototype.callback;

                                                      type AgentCallbackCallback

                                                      type AgentCallbackCallback = (
                                                      err?: Error | null,
                                                      socket?: createAgent.AgentCallbackReturn
                                                      ) => void;

                                                        type AgentCallbackPromise

                                                        type AgentCallbackPromise = (
                                                        req: createAgent.ClientRequest,
                                                        opts: createAgent.RequestOptions
                                                        ) => createAgent.AgentCallbackReturn | Promise<createAgent.AgentCallbackReturn>;

                                                          type AgentCallbackReturn

                                                          type AgentCallbackReturn = Duplex | AgentLike;

                                                            type AgentLike

                                                            type AgentLike = Pick<createAgent.Agent, 'addRequest'> | http.Agent;

                                                              type AgentOptions

                                                              type AgentOptions = {
                                                              timeout?: number;
                                                              };

                                                                type RequestOptions

                                                                type RequestOptions = HttpRequestOptions | HttpsRequestOptions;

                                                                  Package Files (1)

                                                                  Dependencies (1)

                                                                  Dev Dependencies (21)

                                                                  Peer Dependencies (0)

                                                                  No peer dependencies.

                                                                  Badge

                                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/agent-base.

                                                                  • Markdown
                                                                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/agent-base)
                                                                  • HTML
                                                                    <a href="https://www.jsdocs.io/package/agent-base"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>