pub struct HttpRangeFetcher { /* private fields */ }Expand description
HTTP Range transport against a HuggingFace-hosted file.
Opened via HttpRangeReader::open. One authenticated, redirect-free
probe (reusing the chunked-download probe) resolves the file size and
classifies access failures eagerly (gated repos, no Range support).
Every range request then targets the HF /resolve URL and follows
the redirect to a freshly-signed CDN URL; reqwest strips the
Authorization header on the cross-host redirect, so the Bearer
token is never sent to the CDN host.
Per-request re-resolution is required, not just convenient:
Xet-backed repos sign each CDN URL for the exact Range header that
minted it (a ByteRange policy condition in the signed URL), so a CDN
URL stored from the probe can never serve any other range. Re-resolving
also makes signed-URL expiry a non-issue — every request gets a fresh
signature. Discovered live against google/gemma-scope-2b-pt-res
(v0.11.0 dogfooding).
§Response validation (every request)
- Status must be
206 Partial Content. A200(server ignoring theRangeheader) is rejected without reading the body — the guard against silently pulling the full file. Content-Rangemust match the requested range and the probed total size.- The body is streamed with a hard cap of the requested length; over- or under-delivery is an error.
- The response
ETag(when present) must stay identical across requests — a mid-inspect change upstream aborts with a clear error.
Trait Implementations§
Source§impl RangeFetcher for HttpRangeFetcher
impl RangeFetcher for HttpRangeFetcher
Source§fn fetch(
&mut self,
start: u64,
end_inclusive: u64,
) -> Result<Vec<u8>, FetchError>
fn fetch( &mut self, start: u64, end_inclusive: u64, ) -> Result<Vec<u8>, FetchError>
start..=end_inclusive. Read moreSource§fn total_size(&self) -> u64
fn total_size(&self) -> u64
Source§fn extra_requests(&self) -> u32
fn extra_requests(&self) -> u32
RangeFetcher::fetch
(e.g. the eager probe that resolved the file size and classified
access). Included in RangeReader::stats so the reported request
count is honest.