Skip to main content

process_connection

Function process_connection 

Source
pub async fn process_connection<H, Fut>(
    cx: &Cx,
    request_counter: &AtomicU64,
    stream: TcpStream,
    _peer_addr: SocketAddr,
    config: &ServerConfig,
    handler: H,
) -> Result<(), ServerError>
where H: Fn(RequestContext, &mut Request) -> Fut, Fut: Future<Output = Response>,
Expand description

Processes a connection with the given handler.

This is the unified connection handling logic used by all server modes. It runs the parse-dispatch-write loop for HTTP/1.1 (and delegates to [process_connection_http2] when h2c prior-knowledge is detected).

The function is public so that embedders can build custom accept loops while reusing the core per-connection logic.