pub struct Request {
pub url: Url,
pub method: Method,
pub headers: HeaderMap,
pub body: Option<Body>,
pub meta: DashMap<Cow<'static, str>, Value>,
}Fields§
§url: Url§method: Method§headers: HeaderMap§body: Option<Body>§meta: DashMap<Cow<'static, str>, Value>Implementations§
Source§impl Request
impl Request
Sourcepub fn with_method(self, method: Method) -> Request
pub fn with_method(self, method: Method) -> Request
Sets the HTTP method for the request.
Sourcepub fn with_header(
self,
name: &str,
value: &str,
) -> Result<Request, SpiderError>
pub fn with_header( self, name: &str, value: &str, ) -> Result<Request, SpiderError>
Adds a header to the request.
Sourcepub fn with_body(self, body: Body) -> Request
pub fn with_body(self, body: Body) -> Request
Sets the body of the request and defaults the method to POST.
Sourcepub fn with_form(self, form: DashMap<String, String>) -> Request
pub fn with_form(self, form: DashMap<String, String>) -> Request
Sets the body of the request to a form.
Sourcepub fn with_bytes(self, bytes: Bytes) -> Request
pub fn with_bytes(self, bytes: Bytes) -> Request
Sets the body of the request to a byte slice.
Sourcepub fn with_meta(self, key: &str, value: Value) -> Request
pub fn with_meta(self, key: &str, value: Value) -> Request
Adds a value to the request’s metadata.
Sourcepub fn get_retry_attempts(&self) -> u32
pub fn get_retry_attempts(&self) -> u32
Gets the number of times the request has been retried.
Sourcepub fn increment_retry_attempts(&mut self)
pub fn increment_retry_attempts(&mut self)
Increments the retry count for the request.
Sourcepub fn fingerprint(&self) -> String
pub fn fingerprint(&self) -> String
Generates a unique fingerprint for the request based on its URL, method, and body.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Request
impl<'de> Deserialize<'de> for Request
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Request, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Request, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Request
impl Serialize for Request
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl !Freeze for Request
impl !RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnsafeUnpin for Request
impl UnwindSafe for Request
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