pub trait BodyClassifier:
Send
+ Sync
+ 'static {
// Required method
fn classify(
&self,
status: StatusCode,
headers: &HeaderMap,
body: &[u8],
) -> ProxyBodyVerdict;
}Expand description
Classify responses with full body to determine proxy health at business level.
§Example
use reqwest_proxy_pool::{BodyClassifier, ProxyBodyVerdict};
struct CaptchaDetector;
impl BodyClassifier for CaptchaDetector {
fn classify(
&self,
status: reqwest::StatusCode,
_headers: &reqwest::header::HeaderMap,
body: &[u8],
) -> ProxyBodyVerdict {
if status == reqwest::StatusCode::TOO_MANY_REQUESTS
|| String::from_utf8_lossy(body).contains("captcha")
{
ProxyBodyVerdict::ProxyBlocked
} else if status.is_success() {
ProxyBodyVerdict::Success
} else {
ProxyBodyVerdict::Passthrough
}
}
}