mod config;
mod headers;
mod host;
mod pool;
pub use config::{HostConfig, HostConfigs, RateLimitConfig};
pub use host::{Host, HostKey, HostStats, HostStatsMap};
use http::HeaderMap;
pub use pool::{ClientMap, HostPool};
use reqwest::Response;
use url::Url;
use crate::{ErrorKind, Result};
#[derive(Debug, Clone)]
pub(crate) struct CacheableResponse {
pub(crate) status: reqwest::StatusCode,
pub(crate) text: Option<String>,
pub(crate) headers: HeaderMap,
pub(crate) url: Url,
}
impl CacheableResponse {
async fn from_response(response: Response, needs_body: bool) -> Result<Self> {
let status = response.status();
let headers = response.headers().clone();
let url = response.url().clone();
let text = if needs_body {
Some(response.text().await.map_err(ErrorKind::ReadResponseBody)?)
} else {
None
};
Ok(Self {
status,
text,
headers,
url,
})
}
}