pub struct HttpRequest {
pub method: Method,
pub url: Url,
pub headers: HeaderMap,
pub body: Option<Vec<u8>>,
}Expand description
An HTTP request to be sent.
This is a value type that can be constructed and passed to any
HttpClient implementation. It uses standard http crate types
for method and headers, ensuring compatibility with the broader ecosystem.
Fields§
§method: MethodHTTP method (GET, POST, PUT, DELETE, etc.)
url: UrlTarget URL
headers: HeaderMapHTTP headers to send
body: Option<Vec<u8>>Optional request body
Implementations§
Source§impl HttpRequest
impl HttpRequest
Sourcepub fn new(method: Method, url: Url) -> Self
pub fn new(method: Method, url: Url) -> Self
Creates a new HTTP request with the given method and URL.
Headers are initialized to an empty map and body is None.
Sourcepub fn with_header(self, name: HeaderName, value: HeaderValue) -> Self
pub fn with_header(self, name: HeaderName, value: HeaderValue) -> Self
Adds a header to the request.
If the header name already exists, the value is appended (HTTP headers can have multiple values).
Trait Implementations§
Source§impl Clone for HttpRequest
impl Clone for HttpRequest
Source§fn clone(&self) -> HttpRequest
fn clone(&self) -> HttpRequest
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HttpRequest
impl RefUnwindSafe for HttpRequest
impl Send for HttpRequest
impl Sync for HttpRequest
impl Unpin for HttpRequest
impl UnwindSafe for HttpRequest
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