pub struct HttpClient { /* private fields */ }Expand description
HTTP 客户端
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn openapi_endpoint(&self) -> &str
pub fn openapi_endpoint(&self) -> &str
获取 OpenAPI 端点
Sourcepub async fn post_json(
&self,
url: &str,
body: &Value,
access_token: Option<&str>,
) -> Result<Value>
pub async fn post_json( &self, url: &str, body: &Value, access_token: Option<&str>, ) -> Result<Value>
POST JSON 请求,返回解析后的 JSON
Sourcepub async fn put_json(
&self,
url: &str,
body: &Value,
access_token: Option<&str>,
) -> Result<Value>
pub async fn put_json( &self, url: &str, body: &Value, access_token: Option<&str>, ) -> Result<Value>
PUT JSON 请求,返回解析后的 JSON
Sourcepub async fn post_json_raw(
&self,
url: &str,
body: &Value,
) -> Result<(u16, String)>
pub async fn post_json_raw( &self, url: &str, body: &Value, ) -> Result<(u16, String)>
POST JSON 请求,返回原始 (status_code, body_text)
Sourcepub async fn get_bytes_with_limit(
&self,
url: &str,
max_size: u64,
) -> Result<Vec<u8>>
pub async fn get_bytes_with_limit( &self, url: &str, max_size: u64, ) -> Result<Vec<u8>>
GET 请求,返回字节内容(带大小限制)
先检查 Content-Length 响应头,超过 max_size 则直接拒绝;
下载过程中累计检查已读字节数,超限则中止。
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 UnsafeUnpin 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