pub struct PageSignature {
pub url: String,
pub status_code: Option<u16>,
pub body_markers: Vec<String>,
pub header_set: Vec<String>,
pub redirect_url: Option<String>,
pub queue_position_hint: Option<u32>,
pub vendor_hint: Option<String>,
}Expand description
Page signature consumed by the InterstitialClassifier.
The signature is the observation that a previous
acquisition attempt produced. Callers attach the
signature to an AcquisitionRequest
via the
AcquisitionRequest::interstitial
field (see mod.rs for the runner integration).
§Example
use stygian_browser::interstitial_router::PageSignature;
let signature = PageSignature::new(
"https://example.com/cdn-cgi/challenge-platform/h/b",
Some(403),
)
.with_body_marker("cf-chl-bypass")
.with_header("cf-mitigated");
assert_eq!(signature.body_markers.len(), 1);
assert_eq!(signature.header_set.len(), 1);Fields§
§url: StringTarget URL of the page.
status_code: Option<u16>HTTP status code, when known.
body_markers: Vec<String>Body substrings (case-insensitive) observed in the page. Markers are normalised to lower-case ASCII.
header_set: Vec<String>Lower-case ASCII header names observed in the response.
redirect_url: Option<String>Optional redirect target for a 3xx response.
queue_position_hint: Option<u32>Optional queue position hint (1-based).
vendor_hint: Option<String>Optional vendor hint (e.g. cloudflare,
akamai).
Implementations§
Source§impl PageSignature
impl PageSignature
Sourcepub fn new(url: impl Into<String>, status_code: Option<u16>) -> Self
pub fn new(url: impl Into<String>, status_code: Option<u16>) -> Self
Build a signature with the supplied url and
status_code and no other fields set.
Sourcepub fn with_body_marker(self, marker: impl Into<String>) -> Self
pub fn with_body_marker(self, marker: impl Into<String>) -> Self
Builder: add a body marker (case-insensitive). The marker is trimmed and lower-cased; empty markers are ignored.
Sourcepub fn with_header(self, header: impl Into<String>) -> Self
pub fn with_header(self, header: impl Into<String>) -> Self
Builder: add a header name (case-insensitive). The name is trimmed and lower-cased; empty names are ignored.
Sourcepub fn with_redirect_url(self, redirect_url: impl Into<String>) -> Self
pub fn with_redirect_url(self, redirect_url: impl Into<String>) -> Self
Builder: set the redirect target.
Sourcepub const fn with_queue_position(self, position: u32) -> Self
pub const fn with_queue_position(self, position: u32) -> Self
Builder: set the queue position hint.
Sourcepub fn with_vendor_hint(self, vendor: impl Into<String>) -> Self
pub fn with_vendor_hint(self, vendor: impl Into<String>) -> Self
Builder: set the vendor hint.
Sourcepub fn with_body_markers(self, markers: Vec<String>) -> Self
pub fn with_body_markers(self, markers: Vec<String>) -> Self
Builder: replace the body marker set.
Sourcepub fn with_header_set(self, headers: Vec<String>) -> Self
pub fn with_header_set(self, headers: Vec<String>) -> Self
Builder: replace the header set.
Sourcepub fn host(&self) -> Option<String>
pub fn host(&self) -> Option<String>
Lower-case ASCII view of the URL host, when
parseable. Returns None when the URL is empty or
malformed.
Sourcepub fn url_contains(&self, needle_lower: &str) -> bool
pub fn url_contains(&self, needle_lower: &str) -> bool
true when the URL path (or query) contains the
given lower-case substring.
Sourcepub fn body_contains(&self, needle_lower: &str) -> bool
pub fn body_contains(&self, needle_lower: &str) -> bool
true when any of the body markers contain the
given lower-case substring.
Sourcepub fn has_header(&self, name_lower: &str) -> bool
pub fn has_header(&self, name_lower: &str) -> bool
true when the header set contains the given
lower-case header name.
Sourcepub fn unique_headers(&self) -> BTreeSet<String>
pub fn unique_headers(&self) -> BTreeSet<String>
Lower-case unique header set (for diagnostics).
Trait Implementations§
Source§impl Clone for PageSignature
impl Clone for PageSignature
Source§fn clone(&self) -> PageSignature
fn clone(&self) -> PageSignature
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PageSignature
impl Debug for PageSignature
Source§impl Default for PageSignature
impl Default for PageSignature
Source§fn default() -> PageSignature
fn default() -> PageSignature
Source§impl<'de> Deserialize<'de> for PageSignature
impl<'de> Deserialize<'de> for PageSignature
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for PageSignature
Source§impl PartialEq for PageSignature
impl PartialEq for PageSignature
Source§fn eq(&self, other: &PageSignature) -> bool
fn eq(&self, other: &PageSignature) -> bool
self and other values to be equal, and is used by ==.