Struct hyper::client::Client [−][src]
pub struct Client<C, B = Body> { /* fields omitted */ }
client and (crate features http1 or http2) only.Expand description
A Client to make outgoing HTTP requests.
Client is cheap to clone and cloning is the recommended way to share a Client. The
underlying connection pool will be reused.
Implementations
Create a new Client with the default config.
Note
The default connector does not handle TLS. Speaking to https
destinations will require configuring a connector that implements
TLS.
pub fn get(&self, uri: Uri) -> ResponseFutureⓘNotable traits for ResponseFuture
impl Future for ResponseFuture type Output = Result<Response<Body>>; where
B: Default,
pub fn get(&self, uri: Uri) -> ResponseFutureⓘNotable traits for ResponseFuture
impl Future for ResponseFuture type Output = Result<Response<Body>>; where
B: Default, Send a GET request to the supplied Uri.
Note
This requires that the HttpBody type have a Default implementation.
It should return an “empty” version of itself, such that
HttpBody::is_end_stream is true.
Example
use hyper::{Client, Uri}; let client = Client::new(); let future = client.get(Uri::from_static("http://httpbin.org/ip"));
pub fn request(&self, req: Request<B>) -> ResponseFutureⓘNotable traits for ResponseFuture
impl Future for ResponseFuture type Output = Result<Response<Body>>;
pub fn request(&self, req: Request<B>) -> ResponseFutureⓘNotable traits for ResponseFuture
impl Future for ResponseFuture type Output = Result<Response<Body>>;Send a constructed Request using this Client.
Example
use hyper::{Body, Method, Client, Request}; let client = Client::new(); let req = Request::builder() .method(Method::POST) .uri("http://httpbin.org/post") .body(Body::from("Hallo!")) .expect("request builder"); let future = client.request(req);
Trait Implementations
type Future = ResponseFuture
type Future = ResponseFutureThe future response value.
Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
type Future = ResponseFuture
type Future = ResponseFutureThe future response value.
Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
Auto Trait Implementations
impl<C, B = Body> !RefUnwindSafe for Client<C, B>impl<C, B = Body> !UnwindSafe for Client<C, B>Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more