pub struct CookieMiddleware {
pub store: Arc<RwLock<CookieStore>>,
}Expand description
Middleware that keeps a shared cookie store across requests.
Fields§
§store: Arc<RwLock<CookieStore>>Implementations§
Source§impl CookieMiddleware
impl CookieMiddleware
Sourcepub fn with_store(store: CookieStore) -> Self
pub fn with_store(store: CookieStore) -> Self
Creates a new CookieMiddleware with a pre-populated CookieStore.
Sourcepub async fn from_json<P: AsRef<Path>>(path: P) -> Result<Self, SpiderError>
pub async fn from_json<P: AsRef<Path>>(path: P) -> Result<Self, SpiderError>
Load cookies from a JSON file, replacing all cookies in the store.
The JSON format is the one used by the cookie_store crate.
Sourcepub async fn from_netscape_file<P: AsRef<Path>>(
path: P,
) -> Result<Self, SpiderError>
pub async fn from_netscape_file<P: AsRef<Path>>( path: P, ) -> Result<Self, SpiderError>
Load cookies from a Netscape cookie file. This will add to, not replace, the existing cookies in the store.
Sourcepub async fn from_rfc6265<P: AsRef<Path>>(path: P) -> Result<Self, SpiderError>
pub async fn from_rfc6265<P: AsRef<Path>>(path: P) -> Result<Self, SpiderError>
Load cookies from a file where each line is a Set-Cookie header value.
The Domain attribute must be explicitly set in each cookie line.
Trait Implementations§
Source§impl Default for CookieMiddleware
impl Default for CookieMiddleware
Source§impl<C: Send + Sync> Middleware<C> for CookieMiddleware
impl<C: Send + Sync> Middleware<C> for CookieMiddleware
Source§fn process_request<'life0, 'life1, 'async_trait>(
&'life0 self,
_client: &'life1 C,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Request>, SpiderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn process_request<'life0, 'life1, 'async_trait>(
&'life0 self,
_client: &'life1 C,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Request>, SpiderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Intercepts an outgoing request before the downloader runs. Read more
Source§fn process_response<'life0, 'async_trait>(
&'life0 self,
response: Response,
) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Response>, SpiderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn process_response<'life0, 'async_trait>(
&'life0 self,
response: Response,
) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Response>, SpiderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Intercepts a successful response after download. Read more
Source§fn handle_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_request: &'life1 Request,
error: &'life2 SpiderError,
) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Request>, SpiderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_request: &'life1 Request,
error: &'life2 SpiderError,
) -> Pin<Box<dyn Future<Output = Result<MiddlewareAction<Request>, SpiderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Handles downloader errors for a request. Read more
Auto Trait Implementations§
impl Freeze for CookieMiddleware
impl !RefUnwindSafe for CookieMiddleware
impl Send for CookieMiddleware
impl Sync for CookieMiddleware
impl Unpin for CookieMiddleware
impl !UnwindSafe for CookieMiddleware
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more