Skip to main content

H1Conn

Struct H1Conn 

Source
pub struct H1Conn { /* private fields */ }
Expand description

An HTTP/1.1 connection wrapping a ConnCtx.

Implementations§

Source§

impl H1Conn

Source

pub async fn connect_tls( addr: SocketAddr, host: &str, ) -> Result<Self, HttpError>

Connect to an HTTP/1.1 server over TLS.

Source

pub async fn connect_plain( addr: SocketAddr, host: &str, ) -> Result<Self, HttpError>

Connect to an HTTP/1.1 server over plaintext TCP.

Source

pub fn set_max_header_section(&mut self, n: usize)

Override the cap on the response header section size (bytes from the status line up to the blank line). Default DEFAULT_MAX_HEADER_SECTION.

Source

pub fn set_max_chunk_size(&mut self, n: usize)

Override the cap on a single chunked-encoding chunk’s payload size. Default DEFAULT_MAX_CHUNK_SIZE.

Source

pub fn set_max_trailer_section(&mut self, n: usize)

Override the cap on the chunked trailer section. Default DEFAULT_MAX_TRAILER_SECTION.

Source

pub fn set_max_body_size(&mut self, n: usize)

Override the cap on the total response body length (Content-Length or accumulated chunked size). Default DEFAULT_MAX_BODY_SIZE.

Source

pub fn set_max_decompressed_size(&mut self, n: usize)

Override the cap on a decompressed response body. Default 64 MiB — defends against decompression bombs where a small compressed input expands to many GiB of zeros.

Source

pub fn peer_will_close(&self) -> bool

Whether the peer signalled it will close after the current response (HTTP/1.0 default, or Connection: close on the response). When true, the application should drop this H1Conn and reconnect for the next request rather than risk a smuggling-class desync.

Source

pub fn conn(&self) -> ConnCtx

Returns the underlying connection context.

Source

pub fn close(&self)

Returns the host name.

Source

pub fn host(&self) -> &str

Source

pub async fn send_request( &mut self, method: &str, path: &str, extra_headers: &[(&str, &str)], body: Option<&[u8]>, ) -> Result<Response, HttpError>

Send an HTTP/1.1 request and receive the response.

Source

pub async fn send_request_streaming( &mut self, method: &str, path: &str, extra_headers: &[(&str, &str)], body: Option<&[u8]>, ) -> Result<H1StreamingResponse<'_>, HttpError>

Send a request and return a streaming response after headers arrive.

The caller must drain the body via H1StreamingResponse::next_chunk() before issuing further requests on this connection.

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.