pub struct HttpClient {
pub(crate) client: Client,
config: HttpConfig,
}Expand description
Enhanced HTTP client with retry logic and error classification
Fields§
§client: Client§config: HttpConfigImplementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn new(config: HttpConfig) -> Result<Self, String>
pub fn new(config: HttpConfig) -> Result<Self, String>
Create a new HTTP client with default configuration
Sourcefn get_device_name() -> &'static str
fn get_device_name() -> &'static str
Get device name based on platform
Sourcepub fn build_auth_header(access_token: Option<&str>, device_id: &str) -> String
pub fn build_auth_header(access_token: Option<&str>, device_id: &str) -> String
Build the value for the Authorization header.
The MediaBrowser scheme, which is the non-deprecated one: Jellyfin 12.0
disables X-Emby-Authorization (and the Emby scheme, X-Emby-Token
and X-MediaBrowser-Token) by default, and a migration turns it off on
upgraded servers too. Authorization: MediaBrowser … is ungated on both
10.11.x and 12.x, so this is one value for both generations rather than a
capability branch.
TRACES: UR-085 | DR-287
Sourcepub fn classify_error(error: &Error) -> ErrorKind
pub fn classify_error(error: &Error) -> ErrorKind
Classify an error for retry logic
Sourcepub fn should_retry(error: &Error) -> bool
pub fn should_retry(error: &Error) -> bool
Check if a request should be retried based on the error
Sourcepub async fn request_with_retry(
&self,
request: Request,
) -> Result<Response, Error>
pub async fn request_with_retry( &self, request: Request, ) -> Result<Response, Error>
Make a request with automatic retry on network errors
Sourcepub async fn get_json_fast<T: DeserializeOwned>(
&self,
url: &str,
) -> Result<T, String>
pub async fn get_json_fast<T: DeserializeOwned>( &self, url: &str, ) -> Result<T, String>
Make a GET request and deserialize JSON with a short timeout and no retries.
Intended for the initial “connect to server” probe on the login screen: a wrong/unreachable URL must fail fast instead of burning through the default 30s-per-attempt timeout and exponential backoff retries.
Trait Implementations§
Source§impl Clone for HttpClient
impl Clone for HttpClient
Source§fn clone(&self) -> HttpClient
fn clone(&self) -> HttpClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more