Fake Mirrors
    Preparing search index...

    Class CurlHttpClient

    Curl-based http-client implementation.

    Uses the high-performance libcurl library via the node-libcurl bindings.

    Depends:

    import { DIContainer } from '@famir/common'
    import { HTTP_CLIENT, HttpClient, CurlHttpClient } from '@famir/http-client'

    // Get container singleton
    const container = DIContainer.getInstance()

    // Register dependency in container
    CurlHttpClient.register(container)

    // Resolve dependency from container
    const httpClient = container.resolve<HttpClient>(HTTP_CLIENT)

    // TODO more examples

    Implements

    • 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.