pub struct HttpClient { /* private fields */ }Expand description
HTTP客户端
封装了HTTP通信的所有细节,包括认证、超时、代理等配置。
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn new(base_url: &str) -> Result<Self, LlmConnectorError>
pub fn new(base_url: &str) -> Result<Self, LlmConnectorError>
创建新的HTTP客户端
Sourcepub fn with_config(
base_url: &str,
timeout_secs: Option<u64>,
proxy: Option<&str>,
) -> Result<Self, LlmConnectorError>
pub fn with_config( base_url: &str, timeout_secs: Option<u64>, proxy: Option<&str>, ) -> Result<Self, LlmConnectorError>
创建带有自定义配置的HTTP客户端
Sourcepub fn with_headers(self, headers: HashMap<String, String>) -> Self
pub fn with_headers(self, headers: HashMap<String, String>) -> Self
添加请求头
Sourcepub fn with_header(self, key: String, value: String) -> Self
pub fn with_header(self, key: String, value: String) -> Self
添加单个请求头
Trait Implementations§
Source§impl Clone for HttpClient
impl Clone for HttpClient
Source§fn clone(&self) -> HttpClient
fn clone(&self) -> HttpClient
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 HttpClient
impl !RefUnwindSafe for HttpClient
impl Send for HttpClient
impl Sync for HttpClient
impl Unpin for HttpClient
impl !UnwindSafe for HttpClient
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