pub struct HttpRequestBuilder(/* private fields */);Expand description
A builder for constructing an HttpRequest.
Implementations§
Source§impl HttpRequestBuilder
impl HttpRequestBuilder
Sourcepub fn push_header(&mut self, name: impl Into<String>, value: impl Into<String>)
pub fn push_header(&mut self, name: impl Into<String>, value: impl Into<String>)
Adds a header to the HTTP request.
§Arguments
name- The name of the header.value- The value of the header.
This method mutably modifies the builder, allowing headers to be added in sequence.
Sourcepub fn set_timeout(&mut self, timeout_ms: u64)
pub fn set_timeout(&mut self, timeout_ms: u64)
Sets a timeout for the HTTP request in milliseconds.
§Arguments
timeout_ms- The duration of the timeout in milliseconds.
This method mutably modifies the builder, setting an optional timeout for the request.
Sourcepub fn json<T: Serialize + ?Sized>(self, body: &T) -> HttpRequest
pub fn json<T: Serialize + ?Sized>(self, body: &T) -> HttpRequest
Sets a JSON body for the HTTP request and adds the appropriate Content-Type header.
§Type Parameters
T- A type that implementsSerialize.
§Arguments
body- The data to be serialized into JSON format and set as the body of the request.
This method constructs a new HttpRequest with a JSON payload, returning it for execution.
Sourcepub fn form<T: Serialize + ?Sized>(self, body: &T) -> HttpRequest
pub fn form<T: Serialize + ?Sized>(self, body: &T) -> HttpRequest
Sets a form-encoded body for the HTTP request and adds the appropriate Content-Type header.
§Type Parameters
T- A type that implementsSerialize.
§Arguments
body- The data to be serialized into form-urlencoded format and set as the body of the request.
This method constructs a new HttpRequest with a URL-encoded payload, returning it for execution.
Sourcepub fn body(self, body: Vec<u8>) -> HttpRequest
pub fn body(self, body: Vec<u8>) -> HttpRequest
Sets a raw byte array as the body for the HTTP request.
§Arguments
body- The data to be set as the body of the request inVec<u8>format.
This method constructs and returns a new HttpRequest with the specified body.
Sourcepub fn build(self) -> HttpRequest
pub fn build(self) -> HttpRequest
Constructs a fully configured HttpRequest from the builder.