fgb-vt - v1.0.4
    Preparing search index...

    Class HttpConnector

    HTTP(S) connector using the Node.js built-in fetch (Node 18+) with HTTP Range Requests.

    Suitable for any HTTP endpoint that supports partial content responses: static file servers, CDNs, cloud storage with pre-signed URLs, etc. Multi-range reads are throttled to HttpConnectorOptions.maxConcurrency concurrent requests to avoid overwhelming the origin.

    import { HttpConnector } from 'fgb-vt';

    const connector = new HttpConnector({
    headers: { Authorization: 'Bearer my-token' },
    timeout: 15_000,
    maxConcurrency: 4,
    retry: { attempts: 5, backoff: 300 },
    });

    const bytes = await connector.read(
    'https://cdn.example.com/data/buildings.fgb',
    0,
    1024,
    );

    await connector.close();

    Implements

    Index

    Constructors

    Methods

    Constructors

    Methods

    • No-op for the HTTP connector.

      The built-in fetch API does not maintain persistent connections that require explicit cleanup. This method exists to satisfy the Connector interface contract.

      Returns Promise<void>

      Resolves immediately.

    • Read a contiguous byte range from an HTTP(S) URL using a Range: bytes=offset-(offset+length-1) request header.

      Expects the server to respond with HTTP 206 Partial Content. Any 2xx response is also accepted for compatibility with servers that ignore Range headers and return the full body.

      Parameters

      • path: string

        Fully qualified HTTP(S) URL to the FGB resource.

      • offset: number

        Zero-based byte offset to begin reading from.

      • length: number

        Number of bytes to read.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      The requested byte range.

      If the server returns a non-success status code (after exhausting retries) with a message containing the HTTP status, path, and byte range.

    • Read multiple byte ranges from the same HTTP(S) URL.

      Each range is fetched as a separate HTTP Range Request. Requests are dispatched through a worker pool limited to HttpConnectorOptions.maxConcurrency concurrent fetches. Results are returned in the same order as the input ranges.

      Parameters

      • path: string

        Fully qualified HTTP(S) URL to the FGB resource.

      • ranges: readonly { length: number; offset: number }[]

        Array of { offset, length } byte-range descriptors.

      Returns Promise<Uint8Array<ArrayBufferLike>[]>

      Array of Uint8Array chunks in the same order as the input ranges. Returns an empty array when ranges is empty.

      If any individual range request fails after retries.