pub struct HttpRequestSender<T> { /* private fields */ }Available on crate feature
http_support only.Expand description
A builder to create a task to send http request.
Implementations§
Source§impl<T> HttpRequestSender<T>
impl<T> HttpRequestSender<T>
Sourcepub fn new(request: Result<Request<T>>) -> Self
pub fn new(request: Result<Request<T>>) -> Self
Create HttpRequestSender with the default configuration other than provided Request.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set the request send / response header recv timeout. the default value is 30s.
Sourcepub fn redirect<R: ToSocketAddrs>(self, raddrs: R) -> Self
pub fn redirect<R: ToSocketAddrs>(self, raddrs: R) -> Self
Rewrite http request’s host:port fields and send request to the specified raddrs.
Sourcepub fn with_server_name(self, server_name: &str) -> Self
pub fn with_server_name(self, server_name: &str) -> Self
Set remote server’s server name, this option will rewrite request’s host field.
Sourcepub fn with_ca_file<P: AsRef<Path>>(self, ca_file: P) -> Self
pub fn with_ca_file<P: AsRef<Path>>(self, ca_file: P) -> Self
Set the server verification ca file, this is useful for self signed server.
Sourcepub async fn create(self) -> Result<(Request<T>, HttpClientWrite, Duration)>
pub async fn create(self) -> Result<(Request<T>, HttpClientWrite, Duration)>
Consume self and create new HttpClientWrite.
On success, The response wait timeout and the original Request are returned together.
Sourcepub async fn response(self) -> Result<Response<BodyReader<HttpClientRead>>>
pub async fn response(self) -> Result<Response<BodyReader<HttpClientRead>>>
Start a new
pub async fn stream_response( self, ) -> Result<Response<BodyReader<HttpClientRead>>>
Auto Trait Implementations§
impl<T> !Freeze for HttpRequestSender<T>
impl<T> !RefUnwindSafe for HttpRequestSender<T>
impl<T> Send for HttpRequestSender<T>where
T: Send,
impl<T> Sync for HttpRequestSender<T>where
T: Sync,
impl<T> Unpin for HttpRequestSender<T>where
T: Unpin,
impl<T> !UnwindSafe for HttpRequestSender<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more