pub struct HttpClient { /* private fields */ }Expand description
HTTPS client bound to product allowlist and config.
Shareable across tasks (&self): rate-limit clock uses a short-lived
Mutex around the map only; sleeps run without holding the lock.
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn new(cfg: Config, cancel: CancelFlag) -> AppResult<Self>
pub fn new(cfg: Config, cancel: CancelFlag) -> AppResult<Self>
Build a client with rustls, default headers, and redirect allowlist.
Owned by one one-shot command. Call sites may Config::clone before passing
cfg when they still need the parent config after construction. That clone is
intentional and cheap relative to TLS/RTT/body I/O. crate::concurrency::ConcurrencyBudget is
built from cfg.max_concurrency (0 = auto).
§Errors
Returns crate::error::ErrorKind::Config when the User-Agent is not a valid header value.
Returns crate::error::ErrorKind::Network when the reqwest client cannot be built.
Sourcepub fn cancel_flag(&self) -> &CancelFlag
pub fn cancel_flag(&self) -> &CancelFlag
Shared cancel flag for cooperative shutdown (HTTP + CPU scrape).
Sourcepub fn budget(&self) -> &ConcurrencyBudget
pub fn budget(&self) -> &ConcurrencyBudget
Shared concurrency budget for CPU-bound parse work.
Sourcepub fn retry_policy(&self) -> RetryConfig
pub fn retry_policy(&self) -> RetryConfig
Resolved retry policy (for doctor / tests).
Sourcepub async fn get_json(&self, url: &Url) -> AppResult<HttpResponse>
pub async fn get_json(&self, url: &Url) -> AppResult<HttpResponse>
GET expecting JSON (Accept: application/json).
§Errors
Returns crate::error::ErrorKind::Network for allowlist, redirect, TLS, or body-cap failures.
Returns crate::error::ErrorKind::Timeout when the wall-clock budget expires.
Returns crate::error::ErrorKind::Interrupted or crate::error::ErrorKind::Terminated on cancel
(kind preserved from the first CancelFlag::cancel_with).
Maps HTTP statuses via AppError::from_http_status (e.g. not-found, rate-limit).