Skip to main content

HttpClientStd

Struct HttpClientStd 

Source
pub struct HttpClientStd { /* private fields */ }
Available on crate feature client only.
Expand description

Std-blocking HTTP client wrapping a boxed Read + Write + Send stream.

Implementations§

Source§

impl HttpClientStd

Source

pub fn new<S: Read + Write + Send + 'static>(stream: S) -> Self

Wraps a pre-connected stream; caller handles TCP and TLS.

Source

pub fn connect(url: &Url, tls: &Tls) -> Result<Self, HttpClientStdError>

Available on crate features 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).

Source

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).

Source

pub fn run<C, T, E>(&mut self, coroutine: C) -> Result<T, HttpClientStdError>
where C: HttpCoroutine<Yield = HttpYield, Return = Result<T, E>>, HttpClientStdError: From<E>,

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.

Source

pub fn send( &mut self, request: HttpRequest, ) -> Result<HttpSendOutput, HttpClientStdError>

Source

pub fn send_http10( &mut self, request: HttpRequest, ) -> Result<HttpSendOutput, HttpClientStdError>

HTTP/1.0 counterpart of Self::send.

Source§

impl HttpClientStd

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.