pub struct Request { /* private fields */ }Expand description
A network request.
This type represents an HTTP request and provides access to request details such as URL, method, headers, and body.
Implementations§
Source§impl Request
impl Request
Sourcepub fn headers(&self) -> &HashMap<String, String>
pub fn headers(&self) -> &HashMap<String, String>
Get the request headers.
Note: Headers are case-insensitive but the map preserves the original case.
Sourcepub fn header_value(&self, name: &str) -> Option<&str>
pub fn header_value(&self, name: &str) -> Option<&str>
Get a header value by name (case-insensitive).
Sourcepub async fn all_headers(&self) -> HashMap<String, String>
pub async fn all_headers(&self) -> HashMap<String, String>
Get all headers asynchronously.
This may fetch additional headers that weren’t available synchronously.
Sourcepub fn post_data_buffer(&self) -> Option<Vec<u8>>
pub fn post_data_buffer(&self) -> Option<Vec<u8>>
Get the POST data as bytes.
Sourcepub fn post_data_json<T: DeserializeOwned>(&self) -> Result<Option<T>, Error>
pub fn post_data_json<T: DeserializeOwned>(&self) -> Result<Option<T>, Error>
Parse the POST data as JSON.
§Errors
Returns an error if the data is not valid JSON or doesn’t match type T.
Sourcepub fn resource_type(&self) -> ResourceType
pub fn resource_type(&self) -> ResourceType
Get the resource type.
Check if this is a navigation request.
Sourcepub fn redirected_from(&self) -> Option<&Request>
pub fn redirected_from(&self) -> Option<&Request>
Get the request that caused this redirect, if any.
Sourcepub fn redirected_to(&self) -> Option<&Request>
pub fn redirected_to(&self) -> Option<&Request>
Get the request that this request redirected to, if any.
Sourcepub fn timing(&self) -> Option<&RequestTiming>
pub fn timing(&self) -> Option<&RequestTiming>
Get request timing information.
Sourcepub async fn sizes(&self) -> RequestSizes
pub async fn sizes(&self) -> RequestSizes
Get request size information.
Returns request body size and headers size.