pub struct H1Conn { /* private fields */ }Expand description
An HTTP/1.1 connection wrapping a ConnCtx.
Implementations§
Source§impl H1Conn
impl H1Conn
Sourcepub async fn connect_tls(
addr: SocketAddr,
host: &str,
) -> Result<Self, HttpError>
pub async fn connect_tls( addr: SocketAddr, host: &str, ) -> Result<Self, HttpError>
Connect to an HTTP/1.1 server over TLS.
Sourcepub async fn connect_plain(
addr: SocketAddr,
host: &str,
) -> Result<Self, HttpError>
pub async fn connect_plain( addr: SocketAddr, host: &str, ) -> Result<Self, HttpError>
Connect to an HTTP/1.1 server over plaintext TCP.
Sourcepub fn set_max_header_section(&mut self, n: usize)
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.
Sourcepub fn set_max_chunk_size(&mut self, n: usize)
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.
Sourcepub fn set_max_trailer_section(&mut self, n: usize)
pub fn set_max_trailer_section(&mut self, n: usize)
Override the cap on the chunked trailer section. Default
DEFAULT_MAX_TRAILER_SECTION.
Sourcepub fn set_max_body_size(&mut self, n: usize)
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.
Sourcepub fn set_max_decompressed_size(&mut self, n: usize)
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.
Sourcepub fn peer_will_close(&self) -> bool
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.
pub fn host(&self) -> &str
Sourcepub async fn send_request(
&mut self,
method: &str,
path: &str,
extra_headers: &[(&str, &str)],
body: Option<&[u8]>,
) -> Result<Response, HttpError>
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.
Sourcepub async fn send_request_streaming(
&mut self,
method: &str,
path: &str,
extra_headers: &[(&str, &str)],
body: Option<&[u8]>,
) -> Result<H1StreamingResponse<'_>, HttpError>
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.