pub struct HttpRequest { /* private fields */ }Expand description
Immutable snapshot of a single HTTP call produced by
crate::HttpRequestBuilder.
Implementations§
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
Sourcepub fn path(&self) -> &str
pub fn path(&self) -> &str
Returns the path segment or absolute URL string stored on this request.
§Returns
The raw path/URL before query string assembly; may be relative if a base URL is set.
Sourcepub fn set_path(&mut self, path: &str) -> &mut Self
pub fn set_path(&mut self, path: &str) -> &mut Self
Replaces the path or absolute URL string.
§Parameters
path: New path or URL string (query string is managed separately viaSelf::add_query_param).
§Returns
self for method chaining.
Sourcepub fn query(&self) -> &[(String, String)]
pub fn query(&self) -> &[(String, String)]
Returns ordered (name, value) query pairs that will be appended to the
resolved URL.
§Returns
Slice view of accumulated query parameters.
Sourcepub fn add_query_param(&mut self, key: &str, value: &str) -> &mut Self
pub fn add_query_param(&mut self, key: &str, value: &str) -> &mut Self
Sourcepub fn clear_query_params(&mut self) -> &mut Self
pub fn clear_query_params(&mut self) -> &mut Self
Sourcepub fn set_typed_header(
&mut self,
name: HeaderName,
value: HeaderValue,
) -> &mut Self
pub fn set_typed_header( &mut self, name: HeaderName, value: HeaderValue, ) -> &mut Self
Inserts one header using pre-validated HeaderName / HeaderValue
types.
§Parameters
name: Typed header name.value: Typed header value.
§Returns
self for method chaining.
Sourcepub fn remove_header(&mut self, name: &HeaderName) -> &mut Self
pub fn remove_header(&mut self, name: &HeaderName) -> &mut Self
Sourcepub fn clear_headers(&mut self) -> &mut Self
pub fn clear_headers(&mut self) -> &mut Self
Clears all request-local headers (defaults and injectors are unaffected until send).
§Returns
self for method chaining.
Sourcepub fn body(&self) -> &HttpRequestBody
pub fn body(&self) -> &HttpRequestBody
Sourcepub fn set_body(&mut self, body: HttpRequestBody) -> &mut Self
pub fn set_body(&mut self, body: HttpRequestBody) -> &mut Self
Replaces the entire body payload.
§Parameters
body: NewHttpRequestBodyvariant.
§Returns
self for method chaining.
Sourcepub fn set_streaming_body(
&mut self,
streaming_body: HttpRequestStreamingBody,
) -> &mut Self
pub fn set_streaming_body( &mut self, streaming_body: HttpRequestStreamingBody, ) -> &mut Self
Sourcepub fn request_timeout(&self) -> Option<Duration>
pub fn request_timeout(&self) -> Option<Duration>
Returns the per-request total timeout, if any.
§Returns
Some(duration) when a request-specific timeout overrides the client
default; otherwise None.
Sourcepub fn set_request_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn set_request_timeout(&mut self, timeout: Duration) -> &mut Self
Sourcepub fn clear_request_timeout(&mut self) -> &mut Self
pub fn clear_request_timeout(&mut self) -> &mut Self
Drops the per-request timeout so the client-wide default applies again.
§Returns
self for method chaining.
Sourcepub fn write_timeout(&self) -> Duration
pub fn write_timeout(&self) -> Duration
Returns the write-phase timeout used while sending the request.
Sourcepub fn set_write_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn set_write_timeout(&mut self, timeout: Duration) -> &mut Self
Sets the write-phase timeout used while sending the request.
Sourcepub fn read_timeout(&self) -> Duration
pub fn read_timeout(&self) -> Duration
Returns the read-phase timeout used while reading response body bytes.
Sourcepub fn set_read_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn set_read_timeout(&mut self, timeout: Duration) -> &mut Self
Sets the read-phase timeout used while reading response body bytes.
Sourcepub fn base_url(&self) -> Option<&Url>
pub fn base_url(&self) -> Option<&Url>
Returns the optional base URL used to resolve relative Self::path
values.
§Returns
Some when a base is configured; None when only absolute URLs in
path are valid.
Sourcepub fn set_base_url(&mut self, base_url: Url) -> &mut Self
pub fn set_base_url(&mut self, base_url: Url) -> &mut Self
Sourcepub fn clear_base_url(&mut self) -> &mut Self
pub fn clear_base_url(&mut self) -> &mut Self
Removes the configured base URL so relative paths can no longer be resolved without resetting it.
§Returns
self for method chaining.
Sourcepub fn ipv4_only(&self) -> bool
pub fn ipv4_only(&self) -> bool
Returns whether IPv6 literal hosts are rejected after URL resolution.
§Returns
true when a resolved URL whose host is an IPv6 literal must be
rejected with HttpError::invalid_url.
Sourcepub fn set_ipv4_only(&mut self, enabled: bool) -> &mut Self
pub fn set_ipv4_only(&mut self, enabled: bool) -> &mut Self
Sourcepub fn cancellation_token(&self) -> Option<&CancellationToken>
pub fn cancellation_token(&self) -> Option<&CancellationToken>
Returns the cooperative cancellation handle, if configured.
§Returns
Some token checked before send and during I/O; None when
cancellation is not wired.
Sourcepub fn set_cancellation_token(&mut self, token: CancellationToken) -> &mut Self
pub fn set_cancellation_token(&mut self, token: CancellationToken) -> &mut Self
Attaches a CancellationToken that can abort this request
cooperatively.
§Parameters
token: Shared cancellation source.
§Returns
self for method chaining.
Sourcepub fn clear_cancellation_token(&mut self) -> &mut Self
pub fn clear_cancellation_token(&mut self) -> &mut Self
Sourcepub fn retry_override(&self) -> &HttpRequestRetryOverride
pub fn retry_override(&self) -> &HttpRequestRetryOverride
Returns the per-request retry override applied by the client pipeline.
§Returns
Borrowed HttpRequestRetryOverride.
Sourcepub fn set_retry_override(
&mut self,
retry_override: HttpRequestRetryOverride,
) -> &mut Self
pub fn set_retry_override( &mut self, retry_override: HttpRequestRetryOverride, ) -> &mut Self
Sourcepub fn resolved_url_cached(&self) -> Option<Url>
pub fn resolved_url_cached(&self) -> Option<Url>
Returns cached resolved URL when available.
Trait Implementations§
Source§impl Clone for HttpRequest
impl Clone for HttpRequest
Auto Trait Implementations§
impl !Freeze for HttpRequest
impl !RefUnwindSafe for HttpRequest
impl Send for HttpRequest
impl Sync for HttpRequest
impl Unpin for HttpRequest
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, D> IntoConfigDefault<T> for Dwhere
D: IntoValueDefault<T>,
impl<T, D> IntoConfigDefault<T> for Dwhere
D: IntoValueDefault<T>,
Source§fn into_config_default(self) -> T
fn into_config_default(self) -> T
T.