pub struct HttpRequest {
pub method: Method,
pub url: String,
pub headers: HashMap<String, String>,
pub body: Body,
pub config: RequestConfig,
/* private fields */
}Expand description
HTTP request data and execution state.
Holds everything needed to issue one outgoing request: method, URL,
headers (single-value HashMap<String, String> — see
hyperlane-standards §8.1), body, and per-request config (timeout,
redirect policy, proxy, decode, etc.).
HttpRequest is constructed either via crate::RequestBuilder or
directly from its public fields, then sent via HttpRequest::send
(sync) or HttpRequest::send_async.
Fields§
§method: MethodHTTP method (Method::Get / Method::Post / …).
url: StringTarget URL (string form, parsed on send).
headers: HashMap<String, String>Request headers (single-value).
body: BodyRequest body.
config: RequestConfigPer-request config: timeout, redirects, proxy, decode, etc.
Implementations§
Source§impl HttpRequest
impl HttpRequest
Sourcepub fn send(&mut self) -> RequestResult
pub fn send(&mut self) -> RequestResult
Send the HTTP request synchronously, returning the parsed response.
Sourcepub async fn send_async(&mut self) -> RequestResult
pub async fn send_async(&mut self) -> RequestResult
Send the HTTP request asynchronously, returning the parsed response.
Source§impl HttpRequest
impl HttpRequest
pub fn get_mut_headers(&mut self) -> &mut HashMap<String, String>
Source§impl HttpRequest
impl HttpRequest
Sourcepub fn set_method(&mut self, method: Method) -> &mut Self
pub fn set_method(&mut self, method: Method) -> &mut Self
Builder-style: set method.
Sourcepub fn set_header<K: AsRef<str>, V: AsRef<str>>(
&mut self,
key: K,
value: V,
) -> &mut Self
pub fn set_header<K: AsRef<str>, V: AsRef<str>>( &mut self, key: K, value: V, ) -> &mut Self
Builder-style: set a single header (case-insensitive on read; the last value wins for repeated keys).
Sourcepub fn remove_header<K: AsRef<str>>(&mut self, key: K) -> &mut Self
pub fn remove_header<K: AsRef<str>>(&mut self, key: K) -> &mut Self
Remove a header by key.
Sourcepub fn clear_headers(&mut self) -> &mut Self
pub fn clear_headers(&mut self) -> &mut Self
Clear all headers.
Sourcepub fn set_config(&mut self, config: RequestConfig) -> &mut Self
pub fn set_config(&mut self, config: RequestConfig) -> &mut Self
Set a single config field by mutating the embedded RequestConfig.
Sourcepub fn get_method(&self) -> Method
pub fn get_method(&self) -> Method
Get a copy of the HTTP method.
Sourcepub fn get_url_ref(&self) -> &str
pub fn get_url_ref(&self) -> &str
Get a reference to the URL string.
Sourcepub fn get_headers(&self) -> HashMap<String, String>
pub fn get_headers(&self) -> HashMap<String, String>
Get a clone of the request headers map.
Sourcepub fn get_headers_ref(&self) -> &HashMap<String, String>
pub fn get_headers_ref(&self) -> &HashMap<String, String>
Get a reference to the request headers map.
Sourcepub fn get_headers_mut(&mut self) -> &mut HashMap<String, String>
pub fn get_headers_mut(&mut self) -> &mut HashMap<String, String>
Returns a mutable reference to the headers map.
§Returns
&mut HashMap<String, String>- The mutable headers map.
Sourcepub fn get_body_ref(&self) -> &Body
pub fn get_body_ref(&self) -> &Body
Get a reference to the body.
Sourcepub fn get_config(&self) -> RequestConfig
pub fn get_config(&self) -> RequestConfig
Get a clone of the request config.
Sourcepub fn get_config_ref(&self) -> &RequestConfig
pub fn get_config_ref(&self) -> &RequestConfig
Get a reference to the request config.
Sourcepub fn get_config_mut(&mut self) -> &mut RequestConfig
pub fn get_config_mut(&mut self) -> &mut RequestConfig
Get a mutable reference to the request config.