pub struct HttpClientConfigBuilder { /* private fields */ }Expand description
HTTP 客户端配置构建器
Implementations§
Source§impl HttpClientConfigBuilder
impl HttpClientConfigBuilder
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
设置连接超时
Sourcepub fn request_timeout(self, timeout: Duration) -> Self
pub fn request_timeout(self, timeout: Duration) -> Self
设置请求超时
Sourcepub fn user_agent(self, ua: impl Into<String>) -> Self
pub fn user_agent(self, ua: impl Into<String>) -> Self
设置用户代理
Sourcepub fn max_retries(self, retries: u32) -> Self
pub fn max_retries(self, retries: u32) -> Self
设置最大重试次数
Sourcepub fn retry_strategy(self, strategy: RetryStrategy) -> Self
pub fn retry_strategy(self, strategy: RetryStrategy) -> Self
设置重试策略
Sourcepub fn proxy_http(self, url: impl Into<String>) -> Self
pub fn proxy_http(self, url: impl Into<String>) -> Self
设置 HTTP 代理
Sourcepub fn proxy_https(self, url: impl Into<String>) -> Self
pub fn proxy_https(self, url: impl Into<String>) -> Self
设置 HTTPS 代理
Sourcepub fn follow_redirects(self, follow: bool) -> Self
pub fn follow_redirects(self, follow: bool) -> Self
是否跟随重定向
Sourcepub fn max_redirects(self, max: u32) -> Self
pub fn max_redirects(self, max: u32) -> Self
设置最大重定向次数
Sourcepub fn accept_invalid_certs(self, accept: bool) -> Self
pub fn accept_invalid_certs(self, accept: bool) -> Self
是否接受无效证书(危险:仅用于测试)
Sourcepub fn build(self) -> HttpClientConfig
pub fn build(self) -> HttpClientConfig
构建配置
Sourcepub fn build_client(self) -> Result<HttpClient, HttpError>
pub fn build_client(self) -> Result<HttpClient, HttpError>
构建客户端(快捷方法)
Trait Implementations§
Source§impl Clone for HttpClientConfigBuilder
impl Clone for HttpClientConfigBuilder
Source§fn clone(&self) -> HttpClientConfigBuilder
fn clone(&self) -> HttpClientConfigBuilder
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 moreSource§impl Debug for HttpClientConfigBuilder
impl Debug for HttpClientConfigBuilder
Source§impl Default for HttpClientConfigBuilder
impl Default for HttpClientConfigBuilder
Source§fn default() -> HttpClientConfigBuilder
fn default() -> HttpClientConfigBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for HttpClientConfigBuilder
impl RefUnwindSafe for HttpClientConfigBuilder
impl Send for HttpClientConfigBuilder
impl Sync for HttpClientConfigBuilder
impl Unpin for HttpClientConfigBuilder
impl UnwindSafe for HttpClientConfigBuilder
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