[][src]Struct chttp::client::Client

pub struct Client { /* fields omitted */ }

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]

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]

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]

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]

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]

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]

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]

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

impl Send for Client

impl Sync for Client

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]