use async_trait::async_trait;
use crate::engine::http_response::HttpResponse;
use crate::error::CrawlerResult;
#[async_trait]
pub trait Fetcher: Send + Sync {
#[allow(clippy::too_many_arguments)]
async fn fetch(
&self,
host: &str,
port: u16,
scheme: &str,
url: &str,
http_method: &str,
timeout_secs: u64,
user_agent: &str,
accept: &str,
accept_encoding: &str,
origin: Option<&str>,
use_http_auth_if_configured: bool,
forced_ip: Option<&str>,
) -> CrawlerResult<HttpResponse>;
#[allow(clippy::too_many_arguments)]
async fn fetch_http_only(
&self,
host: &str,
port: u16,
scheme: &str,
url: &str,
http_method: &str,
timeout_secs: u64,
user_agent: &str,
accept: &str,
accept_encoding: &str,
origin: Option<&str>,
use_http_auth_if_configured: bool,
forced_ip: Option<&str>,
) -> CrawlerResult<HttpResponse> {
self.fetch(
host,
port,
scheme,
url,
http_method,
timeout_secs,
user_agent,
accept,
accept_encoding,
origin,
use_http_auth_if_configured,
forced_ip,
)
.await
}
#[allow(clippy::too_many_arguments)]
fn is_url_cached(
&self,
host: &str,
port: u16,
scheme: &str,
url: &str,
http_method: &str,
user_agent: &str,
accept: &str,
accept_encoding: &str,
origin: Option<&str>,
) -> bool;
async fn shutdown(&self) {}
}