fgb-vt - v1.0.6
    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. Requests are limited to HttpConnectorOptions.maxConcurrency in flight across all reads of the connector, to avoid overwhelming the origin.

    import { HttpConnector } from '@geozelot/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
    cacheNamespace: string

    URLs identify resources globally, given the same request headers.

    Optional tuning hints for the pipeline.

    • 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 HTTP 206 Partial Content starting at offset (checked against Content-Range when present). Other outcomes:

      • 416 Range Not Satisfiable (range starts at or beyond the end of the resource) → empty result, consistent with reading past EOF.
      • 200 OK (server ignored Range) → accepted only for reads from offset 0 whose full body fits within length; otherwise a RangeNotSupportedError, because every later read would silently download the whole file.
      • A response whose ETag (or Last-Modified) differs from ReadOptions.ifMatch, or 412 Precondition Failed (with conditionalRequests) → SourceChangedError.
      • A response shorter than its Content-Range → retried; a server that returns less than requested (a cap on range sizes) is asked for the rest.

      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.

      • Optionaloptions: ReadOptions

        Optional version check and abort signal.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      The requested byte range; shorter than length if the resource ends first.

      On non-success status codes (after exhausting retries for transient ones) and mismatched Content-Range responses.

      If the server ignores Range.

      If ifMatch no longer matches.

    • Read the first length bytes together with the resource size (from Content-Range, or a HEAD request when the server reports *) and version tag (ETag, or Last-Modified without one).

      Parameters

      • path: string

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

      • length: number

        Number of leading bytes to read.

      • Optionaloptions: ReadOptions

        Optional abort signal.

      Returns Promise<ReadHeadResult>

      The leading bytes plus size and version tag.

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

      Each range is fetched as a separate HTTP Range Request, subject to the connector-wide HttpConnectorOptions.maxConcurrency limit. When one range fails, the others are cancelled. 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.

      • Optionaloptions: ReadOptions

        Optional version check and abort signal, applied to every range.

      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.