pub struct SendRequest<B> { /* private fields */ }
Expand description
The sender side of an established connection.
Implementations§
source§impl<B> SendRequest<B>
impl<B> SendRequest<B>
sourcepub fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>>
pub fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>>
Polls to determine whether this sender can be used yet for a request.
If the associated connection is closed, this returns an Error.
sourcepub async fn ready(&mut self) -> Result<()>
pub async fn ready(&mut self) -> Result<()>
Waits until the dispatcher is ready
If the associated connection is closed, this returns an Error.
sourcepub fn is_ready(&self) -> bool
pub fn is_ready(&self) -> bool
Checks if the connection is currently ready to send a request.
§Note
This is mostly a hint. Due to inherent latency of networks, it is possible that even after checking this is ready, sending a request may still fail because the connection was closed in the meantime.
source§impl<B> SendRequest<B>where
B: Body + 'static,
impl<B> SendRequest<B>where
B: Body + 'static,
sourcepub fn send_request(
&mut self,
req: Request<B>,
) -> impl Future<Output = Result<Response<IncomingBody>>>
pub fn send_request( &mut self, req: Request<B>, ) -> impl Future<Output = Result<Response<IncomingBody>>>
Sends a Request
on the associated connection.
Returns a future that if successful, yields the Response
.
req
must have a Host
header.
§Uri
The Uri
of the request is serialized as-is.
- Usually you want origin-form (
/path?query
). - For sending to an HTTP proxy, you want to send in absolute-form
(
https://hyper.rs/guides
).
This is however not enforced or validated and it is up to the user
of this method to ensure the Uri
is correct for their intended purpose.
sourcepub fn try_send_request(
&mut self,
req: Request<B>,
) -> impl Future<Output = Result<Response<IncomingBody>, TrySendError<Request<B>>>>
pub fn try_send_request( &mut self, req: Request<B>, ) -> impl Future<Output = Result<Response<IncomingBody>, TrySendError<Request<B>>>>
Sends a Request
on the associated connection.
Returns a future that if successful, yields the Response
.
§Error
If there was an error before trying to serialize the request to the connection, the message will be returned as part of this error.