pub struct HttpClientStd { /* private fields */ }client only.Expand description
Std-blocking HTTP client wrapping a boxed Read + Write + Send stream.
Implementations§
Source§impl HttpClientStd
impl HttpClientStd
Sourcepub fn new<S: Read + Write + Send + 'static>(stream: S) -> Self
pub fn new<S: Read + Write + Send + 'static>(stream: S) -> Self
Wraps a pre-connected stream; caller handles TCP and TLS.
Sourcepub fn connect(url: &Url, tls: &Tls) -> Result<Self, HttpClientStdError>
Available on crate features native-tls or rustls-aws or rustls-ring only.
pub fn connect(url: &Url, tls: &Tls) -> Result<Self, HttpClientStdError>
native-tls or rustls-aws or rustls-ring only.Connects to url (TLS handshake on https), reading ALPN from
tls.rustls.alpn (see default_alpn).
Sourcepub fn set_stream<S: Read + Write + Send + 'static>(&mut self, stream: S)
pub fn set_stream<S: Read + Write + Send + 'static>(&mut self, stream: S)
Replaces the underlying stream (e.g. after Connection: close or
a cross-authority redirect).
Sourcepub fn run<C, T, E>(&mut self, coroutine: C) -> Result<T, HttpClientStdError>
pub fn run<C, T, E>(&mut self, coroutine: C) -> Result<T, HttpClientStdError>
Drives any standard-shape coroutine against the wrapped stream
until it completes. Coroutines with richer Yield variants
(Http*Send, Http11ReadChunksStream, SseFrameParser) use
their own per-method loops below.
Sourcepub fn send(
&mut self,
request: HttpRequest,
) -> Result<HttpSendOutput, HttpClientStdError>
pub fn send( &mut self, request: HttpRequest, ) -> Result<HttpSendOutput, HttpClientStdError>
Runs Http11Send; surfaces 3xx as
HttpClientStdError::UnexpectedRedirect.
Sourcepub fn send_http10(
&mut self,
request: HttpRequest,
) -> Result<HttpSendOutput, HttpClientStdError>
pub fn send_http10( &mut self, request: HttpRequest, ) -> Result<HttpSendOutput, HttpClientStdError>
HTTP/1.0 counterpart of Self::send.
Source§impl HttpClientStd
impl HttpClientStd
Sourcepub fn send_streaming(
self,
request: HttpRequest,
) -> Result<SseStream, HttpClientStdError>
pub fn send_streaming( self, request: HttpRequest, ) -> Result<SseStream, HttpClientStdError>
Opens an HTTP/1.1 SSE stream; requires Transfer-Encoding: chunked.
Consumes self because the connection is dedicated to the stream.