pub struct Client {
pub transport: Arc<dyn RoundTripper>,
pub timeout: Option<Duration>,
pub max_redirects: usize,
pub jar: Option<Arc<dyn CookieJar>>,
}Expand description
An HTTP client. Mirrors Go’s http.Client.
Fields§
§transport: Arc<dyn RoundTripper>Transport used for request execution.
timeout: Option<Duration>Per-request timeout; None means no timeout.
max_redirects: usizeMaximum number of redirects to follow (default 10, matching Go).
jar: Option<Arc<dyn CookieJar>>Optional cookie jar.
Implementations§
Source§impl Client
impl Client
Sourcepub fn get(&self, url: &str) -> Result<Response, HttpError>
pub fn get(&self, url: &str) -> Result<Response, HttpError>
Issue a GET request. Port of Go’s (*Client).Get.
Sourcepub fn post(
&self,
url: &str,
content_type: &str,
body: Body,
) -> Result<Response, HttpError>
pub fn post( &self, url: &str, content_type: &str, body: Body, ) -> Result<Response, HttpError>
Issue a POST request with the given content type and body.
Port of Go’s (*Client).Post.
Sourcepub fn post_form(
&self,
url: &str,
values: &[(&str, &str)],
) -> Result<Response, HttpError>
pub fn post_form( &self, url: &str, values: &[(&str, &str)], ) -> Result<Response, HttpError>
Issue a POST request with application/x-www-form-urlencoded body.
Port of Go’s (*Client).PostForm.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
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