pub struct HttpSession {
pub session_id: String,
pub domain: String,
pub cookies: HashMap<String, String>,
pub auth_headers: HashMap<String, String>,
pub csrf_token: Option<String>,
pub auth_type: AuthType,
pub created_at: f64,
pub expires_at: Option<f64>,
}Expand description
An authenticated HTTP session.
Fields§
§session_id: StringUnique session identifier.
domain: StringDomain this session is valid for.
Session cookies (name -> value).
auth_headers: HashMap<String, String>Authentication headers to include (header-name -> value).
csrf_token: Option<String>CSRF token if discovered.
auth_type: AuthTypeType of authentication used.
created_at: f64Unix timestamp when session was created.
expires_at: Option<f64>Unix timestamp when session expires, if known.
Implementations§
Source§impl HttpSession
impl HttpSession
Sourcepub fn new(domain: &str, auth_type: AuthType) -> Self
pub fn new(domain: &str, auth_type: AuthType) -> Self
Create a new session for the given domain with the specified auth type.
Generates a unique session ID from the current timestamp and an atomic counter. Cookies and auth headers start empty.
Format cookies as a Cookie header value.
Returns a string like name1=val1; name2=val2. The order of cookies
is sorted by name for deterministic output.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check whether this session has expired.
Returns false if no expiry is set.
Add a cookie to this session.
Sourcepub fn add_auth_header(&mut self, name: &str, value: &str)
pub fn add_auth_header(&mut self, name: &str, value: &str)
Add an authentication header to this session.
Sourcepub fn set_expires(&mut self, unix_timestamp: f64)
pub fn set_expires(&mut self, unix_timestamp: f64)
Set the expiry timestamp for this session.
Trait Implementations§
Source§impl Clone for HttpSession
impl Clone for HttpSession
Source§fn clone(&self) -> HttpSession
fn clone(&self) -> HttpSession
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more