HttpRangeReader
Defined in: io/http-reader.ts:49
A RandomAccessReader over an HTTP(S) URL using Range requests.
The result of a read is assembled from the bytes actually fetched, so it
is correct regardless of cache eviction; the LRU page cache is purely an
optimization for overlapping reads. A short 206 is followed up until
the requested range is satisfied. End of file is concluded only from the
known size or a 416, never from a cache miss. A server that never
honors Range (a 200 to the initial probe) is read whole, once. After
the probe succeeds with 206, a later full-body 200 throws rather than
mixing two representations. Detecting a mid-read change needs a server
validator (ETag/Last-Modified, replayed as If-Range); with none, a
resource that changes but keeps answering 206 is not detected.
Remarks
Section titled “Remarks”The page cache is best-effort: two concurrent reads missing the same
page may each fetch it. When the total size is unknown a read allocates
the caller-supplied length up front, so callers pass bounded lengths.
A failed initial probe is sticky: every later read rethrows it, by
design (a dead URL is not re-hammered); build a new reader to retry.
Example
Section titled “Example”const reader = new HttpRangeReader("https://example.org/image.fits");const header = await reader.read(0, 2880);Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new HttpRangeReader(_url, options?): HttpRangeReader;Defined in: io/http-reader.ts:65
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
_url |
string | URL |
options |
HttpRangeReaderOptions |
Returns
Section titled “Returns”HttpRangeReader
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get size(): number | undefined;Defined in: io/http-reader.ts:85
Total length in bytes, or undefined if the source size is unknown.
Returns
Section titled “Returns”number | undefined
Total length in bytes, or undefined if the source size is unknown.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”read()
Section titled “read()”read(offset, length): Promise<Uint8Array<ArrayBufferLike>>;Defined in: io/http-reader.ts:284
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
offset |
number |
length |
number |
Returns
Section titled “Returns”Promise<Uint8Array<ArrayBufferLike>>