pub struct FeedHttpClient { /* private fields */ }Expand description
HTTP client for fetching feeds
Implementations§
Source§impl FeedHttpClient
impl FeedHttpClient
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates a new HTTP client with default settings
Default settings:
- 30 second timeout
- Gzip, deflate, and brotli compression enabled
- Maximum 10 redirects, each re-validated against the SSRF checks
- DNS resolution re-validated against the SSRF checks to close DNS-rebinding gaps between validation and connect time
- No system/environment proxy (
HTTP_PROXY,HTTPS_PROXY,ALL_PROXY) is honored: a proxy connects through a hostname that is resolved by the proxy itself, not by the DNS-rebinding-safe resolver above, which would silently defeat that protection - Custom User-Agent
§Errors
Returns FeedError::Http if the underlying HTTP client cannot be created.
Sourcepub fn with_user_agent(self, agent: String) -> Self
pub fn with_user_agent(self, agent: String) -> Self
Sets a custom User-Agent header
§Security
User-Agent is truncated to 512 bytes to prevent header injection attacks.
Sourcepub const fn with_timeout(self, timeout: Duration) -> Self
pub const fn with_timeout(self, timeout: Duration) -> Self
Sets the per-request timeout applied to every Self::get call.
The value is a total deadline covering connection, all redirect hops,
and the full response body — not a per-hop timeout. Duration::ZERO
means “time out immediately”, not “disable the timeout”; this API has
no way to disable it entirely. Values above one hour are clamped to
one hour: reqwest’s blocking wait computes its deadline as
Instant::now() + timeout without an overflow check, so passing
Duration::MAX (or another value near the Instant range limit)
would otherwise panic instead of erroring.
Sourcepub fn get(
&self,
url: &str,
etag: Option<&str>,
modified: Option<&str>,
extra_headers: Option<&HeaderMap>,
) -> Result<FeedHttpResponse>
pub fn get( &self, url: &str, etag: Option<&str>, modified: Option<&str>, extra_headers: Option<&HeaderMap>, ) -> Result<FeedHttpResponse>
Fetches a feed from the given URL
Supports conditional GET with ETag and Last-Modified headers.
§Arguments
url- HTTP/HTTPS URL to fetchetag- OptionalETagfrom previous fetchmodified- OptionalLast-Modifiedfrom previous fetchextra_headers- Additional custom headers
§Errors
Returns FeedError::Http if the request fails or headers are invalid.