pub struct SendRequest<B> { /* private fields */ }
Expand description
The sender side of an established connection.
Implementations
sourceimpl<B> SendRequest<B>
impl<B> SendRequest<B>
sourceimpl<B> SendRequest<B> where
B: HttpBody + 'static,
impl<B> SendRequest<B> where
B: HttpBody + 'static,
sourcepub fn send_request(&mut self, req: Request<B>) -> ResponseFutureⓘNotable traits for ResponseFutureimpl Future for ResponseFuture type Output = Result<Response<Body>>;
pub fn send_request(&mut self, req: Request<B>) -> ResponseFutureⓘNotable traits for ResponseFutureimpl Future for ResponseFuture type Output = Result<Response<Body>>;
Sends a Request
on the associated connection.
Returns a future that if successful, yields the Response
.
Note
There are some key differences in what automatic things the Client
does for you that will not be done here:
Client
requires absolute-formUri
s, since the scheme and authority are needed to connect. They aren’t required here.- Since the
Client
requires absolute-formUri
s, it can add theHost
header based on it. You must add aHost
header yourself before calling this method. - Since absolute-form
Uri
s are not required, if received, they will be serialized as-is.
Example
use hyper::Request;
// build a Request
let req = Request::builder()
.uri("/foo/bar")
.header(HOST, "hyper.rs")
.body(Body::empty())
.unwrap();
// send it and await a Response
let res = tx.send_request(req).await?;
// assert the Response
assert!(res.status().is_success());
Trait Implementations
sourceimpl<B> Debug for SendRequest<B>
impl<B> Debug for SendRequest<B>
sourceimpl<B> Service<Request<B>> for SendRequest<B> where
B: HttpBody + 'static,
impl<B> Service<Request<B>> for SendRequest<B> where
B: HttpBody + 'static,
type Future = ResponseFuture
type Future = ResponseFuture
The future response value.
Auto Trait Implementations
impl<B> !RefUnwindSafe for SendRequest<B>
impl<B> Send for SendRequest<B> where
B: Send,
impl<B> Sync for SendRequest<B> where
B: Send,
impl<B> Unpin for SendRequest<B>
impl<B> !UnwindSafe for SendRequest<B>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more