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) -> Self
pub fn with_method(self, method: Method) -> Self
Sets the HTTP method for the request.
Sourcepub fn with_header(self, name: &str, value: &str) -> Result<Self, SpiderError>
pub fn with_header(self, name: &str, value: &str) -> Result<Self, SpiderError>
Adds a header to the request.
Sourcepub fn with_body(self, body: Body) -> Self
pub fn with_body(self, body: Body) -> Self
Sets the body of the request and defaults the method to POST.
Sourcepub fn with_form(self, form: DashMap<String, String>) -> Self
pub fn with_form(self, form: DashMap<String, String>) -> Self
Sets the body of the request to a form.
Sourcepub fn with_bytes(self, bytes: Bytes) -> Self
pub fn with_bytes(self, bytes: Bytes) -> Self
Sets the body of the request to a byte slice.
Sourcepub fn with_meta(self, key: &str, value: Value) -> Self
pub fn with_meta(self, key: &str, value: Value) -> Self
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. 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 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