Trait isahc::RequestExt
source · pub trait RequestExt<T> {
fn to_builder(&self) -> Builder;
fn send(self) -> Result<Response<Body>, Error>
where
T: Into<Body>;
fn send_async(self) -> ResponseFutureⓘNotable traits for ResponseFutureimpl Future for ResponseFuture type Output = Result<Response<AsyncBody>, Error>;
where
T: Into<AsyncBody>;
}
Expand description
Extension methods on an HTTP request.
Required Methods
sourcefn to_builder(&self) -> Builder
fn to_builder(&self) -> Builder
Create a new request builder with the method, URI, and headers cloned from this request.
Note that third-party extensions are not cloned.
sourcefn send(self) -> Result<Response<Body>, Error>where
T: Into<Body>,
fn send(self) -> Result<Response<Body>, Error>where
T: Into<Body>,
Send the HTTP request synchronously using the default client.
This is a convenience method that is equivalent to
send
.
Examples
use isahc::{prelude::*, Request};
let response = Request::post("https://httpbin.org/post")
.header("Content-Type", "application/json")
.body(r#"{
"speed": "fast",
"cool_name": true
}"#)?
.send()?;
sourcefn send_async(self) -> ResponseFutureⓘNotable traits for ResponseFutureimpl Future for ResponseFuture type Output = Result<Response<AsyncBody>, Error>;
where
T: Into<AsyncBody>,
fn send_async(self) -> ResponseFutureⓘNotable traits for ResponseFutureimpl Future for ResponseFuture type Output = Result<Response<AsyncBody>, Error>;
where
T: Into<AsyncBody>,
Sends the HTTP request asynchronously using the default client.
This is a convenience method that is equivalent to
send_async
.