Skip to main content

HttpClient

Struct HttpClient 

Source
pub struct HttpClient { /* private fields */ }
Available on crate feature http only.
Expand description

Shared, cheaply cloneable (Arc-backed) HTTP client wrapper adding mirror routing, rate-limit inspection, optional retries, and official-origin fallback on top of reqwest::Client.

Implementations§

Source§

impl HttpClient

Source

pub fn new() -> Result<Self>

Creates a new HttpClient with default configuration.

Source

pub fn builder() -> HttpClientBuilder

Returns an HttpClientBuilder for customizing headers, mirror routing, and retries.

Source

pub fn reqwest_client(&self) -> &Client

Returns the underlying reqwest::Client.

Source

pub fn mirror(&self) -> &Mirror

Returns the active Mirror routing strategy.

Source

pub fn resilience(&self) -> &ResiliencePolicy

Returns the active ResiliencePolicy.

Source

pub fn user_agent(&self) -> &str

Returns the configured User-Agent string.

Source

pub fn resolve_url(&self, official_url: &str) -> String

Resolves official_url through the active Mirror.

Source

pub fn candidate_urls(&self, official_url: &str) -> Vec<String>

Returns the ordered candidate URLs that this client will try for official_url, applying Mirror rules and respecting ResiliencePolicy::fallback_to_official.

Unlike Mirror::candidate_urls, which always appends official_url, this omits the trailing official_url when a mirror rewrites official_url and fallback_to_official is false.

Source

pub async fn stream(&self, official_url: &str) -> Result<Response>

Issues a mirror-aware GET request and returns the raw reqwest::Response stream.

Intended for lightweight direct streaming. Callers needing custom request headers, conditional caching (If-None-Match / 304 Not Modified), custom per-download timeouts, or post-download integrity verification failover should combine HttpClient::candidate_urls with HttpClient::reqwest_client.

Trait Implementations§

Source§

impl Clone for HttpClient

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HttpClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<HttpClient> for McApi

Source§

fn from(http: HttpClient) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for HttpClient

§

impl !UnwindSafe for HttpClient

§

impl Forget for HttpClient

§

impl Freeze for HttpClient
where *const ArcInner<HttpClientInner> is !null: Freeze, PhantomData<ArcInner<HttpClientInner>>: Freeze,

§

impl Move for HttpClient

§

impl Send for HttpClient
where Arc<HttpClientInner>: Send,

§

impl Sync for HttpClient
where Arc<HttpClientInner>: Sync,

§

impl Unpin for HttpClient
where Arc<HttpClientInner>: Unpin,

§

impl UnsafeUnpin for HttpClient
where *const ArcInner<HttpClientInner> is !null: UnsafeUnpin, PhantomData<ArcInner<HttpClientInner>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more