[−][src]Struct chttp::client::Client
An HTTP client for making requests.
The client maintains a connection pool internally and is expensive to create, so we recommend re-using your clients instead of discarding and recreating them.
Methods
impl Client
[src]
pub fn new() -> Result<Self, Error>
[src]
Create a new HTTP client using the default configuration.
If the client fails to initialize, an error will be returned.
pub fn builder() -> ClientBuilder
[src]
Create a new builder for building a custom client.
pub fn get<U>(&self, uri: U) -> Result<Response<Body>, Error> where
Uri: HttpTryFrom<U>,
[src]
Uri: HttpTryFrom<U>,
Sends an HTTP GET request.
The response body is provided as a stream that may only be consumed once.
pub fn head<U>(&self, uri: U) -> Result<Response<Body>, Error> where
Uri: HttpTryFrom<U>,
[src]
Uri: HttpTryFrom<U>,
Sends an HTTP HEAD request.
pub fn post<U>(
&self,
uri: U,
body: impl Into<Body>
) -> Result<Response<Body>, Error> where
Uri: HttpTryFrom<U>,
[src]
&self,
uri: U,
body: impl Into<Body>
) -> Result<Response<Body>, Error> where
Uri: HttpTryFrom<U>,
Sends an HTTP POST request.
The response body is provided as a stream that may only be consumed once.
pub fn put<U>(
&self,
uri: U,
body: impl Into<Body>
) -> Result<Response<Body>, Error> where
Uri: HttpTryFrom<U>,
[src]
&self,
uri: U,
body: impl Into<Body>
) -> Result<Response<Body>, Error> where
Uri: HttpTryFrom<U>,
Sends an HTTP PUT request.
The response body is provided as a stream that may only be consumed once.
pub fn delete<U>(&self, uri: U) -> Result<Response<Body>, Error> where
Uri: HttpTryFrom<U>,
[src]
Uri: HttpTryFrom<U>,
Sends an HTTP DELETE request.
The response body is provided as a stream that may only be consumed once.
pub fn send<B: Into<Body>>(
&self,
request: Request<B>
) -> Result<Response<Body>, Error>
[src]
&self,
request: Request<B>
) -> Result<Response<Body>, Error>
Sends a request and returns the response.
The request may include extensions to customize how it is sent. If the
request contains an Options
struct as an extension, then those options will be used
instead of the default options this client is configured with.
The response body is provided as a stream that may only be consumed once.
pub fn send_async<B: Into<Body>>(
&self,
request: Request<B>
) -> impl Future<Item = Response<Body>, Error = Error>
[src]
&self,
request: Request<B>
) -> impl Future<Item = Response<Body>, Error = Error>
Begin sending a request and return a future of the response.
The request may include extensions to customize how it is sent. If the
request contains an Options
struct as an extension, then those options will be used
instead of the default options this client is configured with.
The response body is provided as a stream that may only be consumed once.
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,