pub struct HttpRequestBuilder { /* private fields */ }Expand description
Builder for HttpRequest.
Implementations§
Source§impl HttpRequestBuilder
impl HttpRequestBuilder
Sourcepub fn new(method: Method, path: &str) -> Self
pub fn new(method: Method, path: &str) -> Self
Starts a builder with method and path; body empty, no query, no extra headers.
§Parameters
method: HTTP verb.path: URL or relative path string.
§Returns
New HttpRequestBuilder.
Sourcepub fn query_param(self, key: &str, value: &str) -> Self
pub fn query_param(self, key: &str, value: &str) -> Self
Sourcepub fn query_params<'a, I>(self, params: I) -> Self
pub fn query_params<'a, I>(self, params: I) -> Self
Appends many query pairs via HttpRequestBuilder::query_param.
§Parameters
params: Iterator of(key, value)pairs.
§Returns
self for chaining.
Sourcepub fn header(self, name: &str, value: &str) -> HttpResult<Self>
pub fn header(self, name: &str, value: &str) -> HttpResult<Self>
Validates and inserts one header.
§Parameters
name: Header name (must be validhttp::header::HeaderNamebytes).value: Header value (must be validhttp::header::HeaderValue).
§Returns
Ok(self) or HttpError if name/value are invalid.
Sourcepub fn bytes_body(self, body: impl Into<Bytes>) -> Self
pub fn bytes_body(self, body: impl Into<Bytes>) -> Self
Sourcepub fn json_body<T>(self, value: &T) -> HttpResult<Self>where
T: Serialize,
pub fn json_body<T>(self, value: &T) -> HttpResult<Self>where
T: Serialize,
Sourcepub fn multipart_body(
self,
body: impl Into<Bytes>,
boundary: &str,
) -> HttpResult<Self>
pub fn multipart_body( self, body: impl Into<Bytes>, boundary: &str, ) -> HttpResult<Self>
Sourcepub fn ndjson_body<T>(self, records: &[T]) -> HttpResult<Self>where
T: Serialize,
pub fn ndjson_body<T>(self, records: &[T]) -> HttpResult<Self>where
T: Serialize,
Sourcepub fn cancellation_token(self, token: CancellationToken) -> Self
pub fn cancellation_token(self, token: CancellationToken) -> Self
Binds a CancellationToken to this request.
§Parameters
token: Cancellation token checked before send and during request/stream I/O.
§Returns
self for chaining.
Sourcepub fn force_retry(self) -> Self
pub fn force_retry(self) -> Self
Forces retry enabled for this request even if client-level retry is disabled.
§Returns
self for chaining.
Sourcepub fn disable_retry(self) -> Self
pub fn disable_retry(self) -> Self
Sourcepub fn retry_method_policy(self, policy: HttpRetryMethodPolicy) -> Self
pub fn retry_method_policy(self, policy: HttpRetryMethodPolicy) -> Self
Sourcepub fn honor_retry_after(self, enabled: bool) -> Self
pub fn honor_retry_after(self, enabled: bool) -> Self
Sourcepub fn build(self) -> HttpRequest
pub fn build(self) -> HttpRequest
Trait Implementations§
Source§impl Clone for HttpRequestBuilder
impl Clone for HttpRequestBuilder
Source§fn clone(&self) -> HttpRequestBuilder
fn clone(&self) -> HttpRequestBuilder
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 HttpRequestBuilder
impl RefUnwindSafe for HttpRequestBuilder
impl Send for HttpRequestBuilder
impl Sync for HttpRequestBuilder
impl Unpin for HttpRequestBuilder
impl UnsafeUnpin for HttpRequestBuilder
impl UnwindSafe for HttpRequestBuilder
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