[−][src]Trait surf::middleware::HttpClient
An abstract HTTP client.
note that this is only exposed for use in middleware. Building new backing clients is not
recommended yet. Once it is we'll likely publish a new http_client
crate, and re-export this
trait from there together with all existing HTTP client implementations.
Spawning new request from middleware
When threading the trait through a layer of middleware, the middleware must be able to perform
new requests. In order to enable this we pass an HttpClient
instance through the middleware,
with a Clone
implementation. In order to spawn a new request, clone
is called, and a new
request is enabled.
How Clone
is implemented is up to the implementors, but in an ideal scenario combining this
with the Client
builder will allow for high connection reuse, improving latency.
Associated Types
Loading content...Required methods
fn send(
&self,
req: Request<Body>
) -> Pin<Box<dyn Future<Output = Result<Response<Body>, Self::Error>> + 'static + Send>>
&self,
req: Request<Body>
) -> Pin<Box<dyn Future<Output = Result<Response<Body>, Self::Error>> + 'static + Send>>
Perform a request.
Implementations on Foreign Types
impl HttpClient for IsahcClient
[src]
type Error = Error
fn send(
&self,
req: Request<Body>
) -> Pin<Box<dyn Future<Output = Result<Response<Body>, <IsahcClient as HttpClient>::Error>> + 'static + Send>>
[src]
&self,
req: Request<Body>
) -> Pin<Box<dyn Future<Output = Result<Response<Body>, <IsahcClient as HttpClient>::Error>> + 'static + Send>>