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.Auto Trait Implementations§
impl !RefUnwindSafe for HttpRangeFetcher
impl !UnwindSafe for HttpRangeFetcher
impl Freeze for HttpRangeFetcher
impl Send for HttpRangeFetcher
impl Sync for HttpRangeFetcher
impl Unpin for HttpRangeFetcher
impl UnsafeUnpin for HttpRangeFetcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more