Fake Mirrors
    Preparing search index...

    Interface HttpClient

    Defines the public contract for an http-client.

    Provides methods for making HTTP requests:

    • Simple request/response
    • Streaming request with simple response
    • Simple request with streaming response

    All methods support proxy configuration and timeouts.

    interface HttpClient {
        simple(
            proxy: string,
            method: "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS",
            url: string,
            requestHeaders: HttpHeaders,
            requestBody: HttpBody,
            connectTimeout: number,
            timeout: number,
            headersSizeLimit: number,
            bodySizeLimit: number,
        ): Promise<HttpClientSimpleResult | HttpClientErrorResult>;
        streamRequest(
            proxy: string,
            method: "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS",
            url: string,
            requestHeaders: HttpHeaders,
            requestStream: Readable,
            connectTimeout: number,
            timeout: number,
            headersSizeLimit: number,
            bodySizeLimit: number,
        ): Promise<HttpClientSimpleResult | HttpClientErrorResult>;
        streamResponse(
            proxy: string,
            method: "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS",
            url: string,
            requestHeaders: HttpHeaders,
            requestBody: HttpBody,
            connectTimeout: number,
            timeout: number,
            headersSizeLimit: number,
        ): Promise<HttpClientErrorResult | HttpClientStreamResult>;
    }

    Implemented by

    • Performs a simple HTTP request and returns a simple response.

      Both the request body and response body are fully loaded into memory. Suitable for small to medium-sized payloads.

      Parameters

      • proxy: string

        The proxy URL.

      • method: "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS"

        The request method.

      • url: string

        The target URL.

      • requestHeaders: HttpHeaders

        The request headers to send.

      • requestBody: HttpBody

        The request body as a Buffer.

      • connectTimeout: number

        The connection timeout in milliseconds.

      • timeout: number

        The total request timeout in milliseconds.

      • headersSizeLimit: number

        The maximum headers size in bytes.

      • bodySizeLimit: number

        The maximum body size in bytes.

      Returns Promise<HttpClientSimpleResult | HttpClientErrorResult>

      The result object containing the response or error details.

    • Performs a streaming HTTP request and returns a simple response.

      The request body is streamed from a readable stream, allowing large uploads. The response body is fully loaded into memory.

      Parameters

      • proxy: string

        The proxy URL.

      • method: "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS"

        The request method.

      • url: string

        The target URL.

      • requestHeaders: HttpHeaders

        The request headers to send.

      • requestStream: Readable

        The request body as a readable stream.

      • connectTimeout: number

        The connection timeout in milliseconds.

      • timeout: number

        The total request timeout in milliseconds.

      • headersSizeLimit: number

        The maximum headers size in bytes.

      • bodySizeLimit: number

        The maximum body size in bytes.

      Returns Promise<HttpClientSimpleResult | HttpClientErrorResult>

      The result object containing the response or error details.

    • Performs a simple HTTP request and returns a streaming response.

      The request body is fully loaded into memory, but the response is streamed, allowing large downloads to be processed incrementally.

      Parameters

      • proxy: string

        The proxy URL.

      • method: "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS"

        The request method.

      • url: string

        The target URL.

      • requestHeaders: HttpHeaders

        The request headers to send.

      • requestBody: HttpBody

        The request body as a Buffer.

      • connectTimeout: number

        The connection timeout in milliseconds.

      • timeout: number

        The total request timeout in milliseconds.

      • headersSizeLimit: number

        The maximum headers size in bytes.

      Returns Promise<HttpClientErrorResult | HttpClientStreamResult>

      The result object containing the response or error details.