pub struct HttpClient { /* private fields */ }Expand description
HTTP transport for fetching control files and byte ranges.
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn new() -> Self
pub fn new() -> Self
A client with ureq’s default policy, permitting plain HTTP.
zsync is routinely served over HTTP and across mirror redirects, so
the defaults are permissive on purpose. An embedder with a stricter
policy, such as one that must refuse a downgrade to HTTP or pin its
own trust roots, should build an agent and pass it to
HttpClient::with_agent rather than relying on these.
Sourcepub fn with_agent(agent: Agent) -> Self
pub fn with_agent(agent: Agent) -> Self
A client using a caller-supplied agent.
The agent carries the whole transport policy: TLS roots, whether a redirect may downgrade to HTTP, timeouts and proxies. Supplying one keeps that decision with the embedder, which is the only place that knows what the transferred bytes are trusted for.
pub fn fetch_control_file(&self, url: &str) -> Result<ControlFile, HttpError>
Sourcepub fn fetch_range_reader(
&self,
url: &str,
start: u64,
end: u64,
) -> Result<HttpRangeReader, HttpError>
pub fn fetch_range_reader( &self, url: &str, start: u64, end: u64, ) -> Result<HttpRangeReader, HttpError>
A reader over start..=end of url.
The reader is capped at the requested length. Without that cap the origin decides how much the client reads: a response longer than the range is consumed in full, and callers that accumulate it, such as block assembly, grow a buffer to match. Bytes past the range were never asked for and are of no use, so they are not read.