Skip to main content

Client

Struct Client 

Source
pub struct Client {
    pub url: String,
    pub method: Method,
    pub header: HashMap<String, String>,
    pub content_type: ContentType,
    /* private fields */
}

Fields§

§url: String§method: Method§header: HashMap<String, String>§content_type: ContentType

Implementations§

Source§

impl Client

Source

pub fn new() -> Self

Source

pub fn debug(&mut self) -> &mut Self

Source

pub fn post(&mut self, url: &str) -> &mut Self

Source

pub fn get(&mut self, url: &str) -> &mut Self

Source

pub fn put(&mut self, url: &str) -> &mut Self

Source

pub fn patch(&mut self, url: &str) -> &mut Self

Source

pub fn delete(&mut self, url: &str) -> &mut Self

Source

pub fn head(&mut self, url: &str) -> &mut Self

Source

pub fn options(&mut self, url: &str) -> &mut Self

Source

pub fn trace(&mut self, url: &str) -> &mut Self

Source

pub fn header(&mut self, key: &str, value: &str) -> &mut Self

Source

pub fn query(&mut self, params: JsonValue) -> &mut Self

Source

pub fn set_request_timeout(&mut self, s: usize) -> &mut Self

设置连接超时

Source

pub fn set_response_timeout(&mut self, s: usize) -> &mut Self

Source

pub fn set_retry(&mut self, count: usize) -> &mut Self

Source

pub fn set_command(&mut self, cmd: Vec<String>) -> &mut Self

Source

pub fn raw_json(&mut self, data: JsonValue) -> &mut Self

JSON请求

Source

pub fn raw_xml(&mut self, data: JsonValue) -> &mut Self

Source

pub fn raw_stream(&mut self, filename: &str) -> &mut Self

Source

pub fn raw_binary_str(&mut self, text: &str) -> &mut Self

Source

pub fn raw_stream_urlencode(&mut self, text: &str) -> &mut Self

Source

pub fn form_data(&mut self, data: JsonValue) -> &mut Self

FormData请求

Source

pub fn form_urlencoded(&mut self, data: JsonValue) -> &mut Self

FormData请求

Source

pub fn set_cert_p12(&mut self, filename: &str, password: &str) -> &mut Self

开启旧的ssl

Source

pub fn add_proxy(&mut self, proxy_addr: String)

指定代理

Source

pub fn add_proxy_with_account( &mut self, proxy_addr: String, user: String, password: String, )

指定代理, 该代理需要用户名和密码认证

Source

pub fn send(&mut self) -> Result<Response, String>

Trait Implementations§

Source§

impl Default for Client

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.