pub struct CookieMiddleware {
pub store: Arc<RwLock<CookieStore>>,
}Expand description
Shared cookie jar middleware. Middleware that keeps a shared cookie store across requests.
Fields§
§store: Arc<RwLock<CookieStore>>Implementations§
Source§impl CookieMiddleware
impl CookieMiddleware
Sourcepub fn new() -> CookieMiddleware
pub fn new() -> CookieMiddleware
Creates a new CookieMiddleware with a shared CookieStore.
Sourcepub fn with_store(store: CookieStore) -> CookieMiddleware
pub fn with_store(store: CookieStore) -> CookieMiddleware
Creates a new CookieMiddleware with a pre-populated CookieStore.
Sourcepub async fn from_json<P>(path: P) -> Result<CookieMiddleware, SpiderError>
pub async fn from_json<P>(path: P) -> Result<CookieMiddleware, 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>(
path: P,
) -> Result<CookieMiddleware, SpiderError>
pub async fn from_netscape_file<P>( path: P, ) -> Result<CookieMiddleware, 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>(path: P) -> Result<CookieMiddleware, SpiderError>
pub async fn from_rfc6265<P>(path: P) -> Result<CookieMiddleware, 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§fn default() -> CookieMiddleware
fn default() -> CookieMiddleware
Returns the “default value” for a type. Read more
Source§impl<C> Middleware<C> for CookieMiddleware
impl<C> 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
'life0: 'async_trait,
'life1: 'async_trait,
CookieMiddleware: '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
'life0: 'async_trait,
'life1: 'async_trait,
CookieMiddleware: '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
'life0: 'async_trait,
CookieMiddleware: '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
'life0: 'async_trait,
CookieMiddleware: '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
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: '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
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: '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