Struct object_store::ClientOptions
source · pub struct ClientOptions { /* private fields */ }
Expand description
HTTP client configuration for remote object stores
Implementations§
source§impl ClientOptions
impl ClientOptions
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ClientOptions
with default values
sourcepub fn with_config(self, key: ClientConfigKey, value: impl Into<String>) -> Self
pub fn with_config(self, key: ClientConfigKey, value: impl Into<String>) -> Self
Set an option by key
sourcepub fn get_config_value(&self, key: &ClientConfigKey) -> Option<String>
pub fn get_config_value(&self, key: &ClientConfigKey) -> Option<String>
Get an option by key
sourcepub fn with_user_agent(self, agent: HeaderValue) -> Self
pub fn with_user_agent(self, agent: HeaderValue) -> Self
Sets the User-Agent header to be used by this client
Default is based on the version of this crate
sourcepub fn with_default_content_type(self, mime: impl Into<String>) -> Self
pub fn with_default_content_type(self, mime: impl Into<String>) -> Self
Set the default CONTENT_TYPE for uploads
sourcepub fn with_content_type_for_suffix(
self,
extension: impl Into<String>,
mime: impl Into<String>,
) -> Self
pub fn with_content_type_for_suffix( self, extension: impl Into<String>, mime: impl Into<String>, ) -> Self
Set the CONTENT_TYPE for a given file extension
sourcepub fn with_default_headers(self, headers: HeaderMap) -> Self
pub fn with_default_headers(self, headers: HeaderMap) -> Self
Sets the default headers for every request
sourcepub fn with_allow_http(self, allow_http: bool) -> Self
pub fn with_allow_http(self, allow_http: bool) -> Self
Sets what protocol is allowed. If allow_http
is :
- false (default): Only HTTPS are allowed
- true: HTTP and HTTPS are allowed
sourcepub fn with_allow_invalid_certificates(self, allow_insecure: bool) -> Self
pub fn with_allow_invalid_certificates(self, allow_insecure: bool) -> Self
Allows connections to invalid SSL certificates
- false (default): Only valid HTTPS certificates are allowed
- true: All HTTPS certificates are allowed
§Warning
You should think very carefully before using this method. If invalid certificates are trusted, any certificate for any site will be trusted for use. This includes expired certificates. This introduces significant vulnerabilities, and should only be used as a last resort or for testing
sourcepub fn with_http1_only(self) -> Self
pub fn with_http1_only(self) -> Self
Only use http1 connections
This is on by default, since http2 is known to be significantly slower than http1.
sourcepub fn with_http2_only(self) -> Self
pub fn with_http2_only(self) -> Self
Only use http2 connections
sourcepub fn with_allow_http2(self) -> Self
pub fn with_allow_http2(self) -> Self
Use http2 if supported, otherwise use http1.
sourcepub fn with_proxy_url(self, proxy_url: impl Into<String>) -> Self
pub fn with_proxy_url(self, proxy_url: impl Into<String>) -> Self
Set a proxy URL to use for requests
sourcepub fn with_proxy_ca_certificate(
self,
proxy_ca_certificate: impl Into<String>,
) -> Self
pub fn with_proxy_ca_certificate( self, proxy_ca_certificate: impl Into<String>, ) -> Self
Set a trusted proxy CA certificate
sourcepub fn with_proxy_excludes(self, proxy_excludes: impl Into<String>) -> Self
pub fn with_proxy_excludes(self, proxy_excludes: impl Into<String>) -> Self
Set a list of hosts to exclude from proxy connections
sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set a request timeout
The timeout is applied from when the request starts connecting until the response body has finished
Default is 30 seconds
sourcepub fn with_timeout_disabled(self) -> Self
pub fn with_timeout_disabled(self) -> Self
Disables the request timeout
sourcepub fn with_connect_timeout(self, timeout: Duration) -> Self
pub fn with_connect_timeout(self, timeout: Duration) -> Self
Set a timeout for only the connect phase of a Client
Default is 5 seconds
sourcepub fn with_connect_timeout_disabled(self) -> Self
pub fn with_connect_timeout_disabled(self) -> Self
Disables the connection timeout
sourcepub fn with_pool_idle_timeout(self, timeout: Duration) -> Self
pub fn with_pool_idle_timeout(self, timeout: Duration) -> Self
Set the pool max idle timeout
This is the length of time an idle connection will be kept alive
Default is 90 seconds enforced by reqwest
sourcepub fn with_pool_max_idle_per_host(self, max: usize) -> Self
pub fn with_pool_max_idle_per_host(self, max: usize) -> Self
Set the maximum number of idle connections per host
Default is no limit enforced by reqwest
sourcepub fn with_http2_keep_alive_interval(self, interval: Duration) -> Self
pub fn with_http2_keep_alive_interval(self, interval: Duration) -> Self
Sets an interval for HTTP2 Ping frames should be sent to keep a connection alive.
Default is disabled enforced by reqwest
sourcepub fn with_http2_keep_alive_timeout(self, interval: Duration) -> Self
pub fn with_http2_keep_alive_timeout(self, interval: Duration) -> Self
Sets a timeout for receiving an acknowledgement of the keep-alive ping.
If the ping is not acknowledged within the timeout, the connection will be closed. Does nothing if http2_keep_alive_interval is disabled.
Default is disabled enforced by reqwest
sourcepub fn with_http2_keep_alive_while_idle(self) -> Self
pub fn with_http2_keep_alive_while_idle(self) -> Self
Enable HTTP2 keep alive pings for idle connections
If disabled, keep-alive pings are only sent while there are open request/response streams. If enabled, pings are also sent when no streams are active
Default is disabled enforced by reqwest
sourcepub fn get_content_type(&self, path: &Path) -> Option<&str>
pub fn get_content_type(&self, path: &Path) -> Option<&str>
Get the mime type for the file in path
to be uploaded
Gets the file extension from path
, and returns the
mime type if it was defined initially through
ClientOptions::with_content_type_for_suffix
Otherwise, returns the default mime type if it was defined
earlier through ClientOptions::with_default_content_type
Trait Implementations§
source§impl Clone for ClientOptions
impl Clone for ClientOptions
source§fn clone(&self) -> ClientOptions
fn clone(&self) -> ClientOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ClientOptions
impl Debug for ClientOptions
Auto Trait Implementations§
impl !Freeze for ClientOptions
impl RefUnwindSafe for ClientOptions
impl Send for ClientOptions
impl Sync for ClientOptions
impl Unpin for ClientOptions
impl UnwindSafe for ClientOptions
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more