pub struct H2AsyncConn { /* private fields */ }Expand description
Async HTTP/2 connection with multiplexed request support.
Wraps a sans-IO H2Connection and a ConnCtx, providing a pump loop
that bridges bytes between the transport and the H2 state machine.
Implementations§
Source§impl H2AsyncConn
impl H2AsyncConn
Sourcepub async fn connect(addr: SocketAddr, host: &str) -> Result<Self, HttpError>
pub async fn connect(addr: SocketAddr, host: &str) -> Result<Self, HttpError>
Connect to an HTTP/2 server over TLS.
Performs TLS handshake, sends the H2 connection preface, and waits for the server SETTINGS exchange to complete.
Sourcepub async fn connect_with_timeout(
addr: SocketAddr,
host: &str,
timeout_ms: u64,
) -> Result<Self, HttpError>
pub async fn connect_with_timeout( addr: SocketAddr, host: &str, timeout_ms: u64, ) -> Result<Self, HttpError>
Connect with a timeout (milliseconds).
Sourcepub async fn from_conn(conn: ConnCtx) -> Result<Self, HttpError>
pub async fn from_conn(conn: ConnCtx) -> Result<Self, HttpError>
Wrap an already-connected ConnCtx (must be TLS for H2).
Sends the H2 preface and waits for SETTINGS exchange.
pub fn conn(&self) -> ConnCtx
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Number of in-flight streams.
Sourcepub async fn send_request(
&mut self,
method: &str,
path: &str,
host: &str,
extra_headers: &[(&str, &str)],
body: Option<&[u8]>,
) -> Result<Response, HttpError>
pub async fn send_request( &mut self, method: &str, path: &str, host: &str, extra_headers: &[(&str, &str)], body: Option<&[u8]>, ) -> Result<Response, HttpError>
Send a request and wait for the complete response.
Sourcepub fn fire_request(
&mut self,
method: &str,
path: &str,
host: &str,
extra_headers: &[(&str, &str)],
body: Option<&[u8]>,
) -> Result<u32, HttpError>
pub fn fire_request( &mut self, method: &str, path: &str, host: &str, extra_headers: &[(&str, &str)], body: Option<&[u8]>, ) -> Result<u32, HttpError>
Fire an HTTP/2 request. Returns the stream ID immediately.
The request is queued for sending; call recv() or recv_stream()
to pump the connection and collect responses.
Sourcepub async fn recv(&mut self) -> Result<(u32, Response), HttpError>
pub async fn recv(&mut self) -> Result<(u32, Response), HttpError>
Pump until any stream completes. Returns (stream_id, Response).
Sourcepub async fn recv_stream(
&mut self,
stream_id: u32,
) -> Result<Response, HttpError>
pub async fn recv_stream( &mut self, stream_id: u32, ) -> Result<Response, HttpError>
Pump until a specific stream completes.
Sourcepub async fn send_request_streaming(
&mut self,
method: &str,
path: &str,
host: &str,
extra_headers: &[(&str, &str)],
body: Option<&[u8]>,
) -> Result<H2StreamingResponse<'_>, HttpError>
pub async fn send_request_streaming( &mut self, method: &str, path: &str, host: &str, extra_headers: &[(&str, &str)], body: Option<&[u8]>, ) -> Result<H2StreamingResponse<'_>, HttpError>
Send a request and return a streaming response after headers arrive.
The caller must drain the body via H2StreamingResponse::next_chunk()
before issuing further requests on this connection.