Skip to main content

HttpClientOptions

Struct HttpClientOptions 

Source
pub struct HttpClientOptions {
Show 16 fields pub base_url: Option<Url>, pub default_headers: HeaderMap, pub timeouts: TimeoutOptions, pub proxy: ProxyOptions, pub logging: HttpLoggingOptions, pub error_response_preview_limit: usize, pub user_agent: Option<String>, pub max_redirects: Option<usize>, pub pool_idle_timeout: Option<Duration>, pub pool_max_idle_per_host: Option<usize>, pub retry: HttpRetryOptions, pub sensitive_headers: SensitiveHeaders, pub ipv4_only: bool, pub sse_json_mode: SseJsonMode, pub sse_max_line_bytes: usize, pub sse_max_frame_bytes: usize,
}
Expand description

Aggregated settings for crate::HttpClient and crate::HttpClientFactory.

Fields§

§base_url: Option<Url>

Optional base URL.

§default_headers: HeaderMap

Default request headers.

§timeouts: TimeoutOptions

Timeout options.

§proxy: ProxyOptions

Proxy options.

§logging: HttpLoggingOptions

Logging options.

§error_response_preview_limit: usize

Maximum bytes captured into HttpError.response_body_preview for non-success responses.

§user_agent: Option<String>

Optional default User-Agent header sent by reqwest.

§max_redirects: Option<usize>

Optional redirect limit applied by reqwest.

§pool_idle_timeout: Option<Duration>

Optional connection pool idle-time timeout.

§pool_max_idle_per_host: Option<usize>

Optional maximum idle connections per host.

§retry: HttpRetryOptions

Retry options.

§sensitive_headers: SensitiveHeaders

Sensitive headers for masking.

§ipv4_only: bool

Whether IPv4-only DNS behavior is requested.

§sse_json_mode: SseJsonMode

Default JSON handling mode used by crate::HttpResponse::decode_sse_json_chunks.

§sse_max_line_bytes: usize

Default maximum bytes for one SSE line.

§sse_max_frame_bytes: usize

Default maximum bytes for one SSE frame.

Implementations§

Source§

impl HttpClientOptions

Source

pub fn new() -> Self

Same as HttpClientOptions::default.

§Returns

Fresh options with crate defaults.

Source

pub fn set_base_url( &mut self, base_url: &str, ) -> Result<&mut Self, HttpConfigError>

Parses and sets the base URL used to resolve relative request paths.

§Parameters
  • base_url: Absolute base URL string.
§Returns

Ok(self) or HttpConfigError if the URL is invalid.

Source

pub fn add_header(&mut self, name: &str, value: &str) -> HttpResult<&mut Self>

Validates and adds one client-level default header.

§Parameters
  • name: Header name.
  • value: Header value.
§Returns

Ok(self) or an error if name/value are invalid.

Source

pub fn add_headers<'a, I>(&mut self, headers: I) -> HttpResult<&mut Self>
where I: IntoIterator<Item = (&'a str, &'a str)>,

Validates and adds many client-level default headers atomically.

If any input pair is invalid, no header from this batch is applied.

§Parameters
  • headers: Iterator of (name, value) pairs.
§Returns

Ok(self) or an error if any pair is invalid.

Source

pub fn from_config<R>(config: &R) -> Result<Self, HttpConfigError>
where R: ConfigReader + ?Sized,

Creates HttpClientOptions from config using relative keys.

§Parameters
§Returns

Parsed options or HttpConfigError.

Source

pub fn validate(&self) -> Result<(), HttpConfigError>

Runs ProxyOptions::validate, HttpLoggingOptions::validate, retry validation, and SSE limit validation.

§Returns

Ok(()) or the first sub-validator error.

Trait Implementations§

Source§

impl Clone for HttpClientOptions

Source§

fn clone(&self) -> HttpClientOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HttpClientOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HttpClientOptions

Source§

fn default() -> Self

Default: no base URL, empty headers, default timeouts/proxy/logging, default sensitive headers, IPv4-only off, lenient SSE JSON mode with crate default SSE line/frame limits.

§Returns

Default HttpClientOptions.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more