Skip to main content

run_with_initial_bytes

Function run_with_initial_bytes 

Source
pub async fn run_with_initial_bytes<Transport, Handler, Fut>(
    context: Arc<HttpContext>,
    transport: Transport,
    initial_bytes: Vec<u8>,
    handler: Handler,
) -> Result<Option<Upgrade<Transport>>>
where Transport: AsyncRead + AsyncWrite + Unpin + Send + Sync + 'static, Handler: FnMut(Conn<Transport>) -> Fut, Fut: Future<Output = Conn<Transport>>,
๐Ÿ‘ŽDeprecated since 1.8.0:

use H1Connection::new(context, transport).with_initial_bytes(initial_bytes).run(handler)

Expand description

Like HttpContext::run, but starts with the supplied bytes pre-filled into the request buffer.

For adapters that peek the first few bytes off a cleartext TCP stream to decide between HTTP/1.1 and HTTP/2 prior-knowledge dispatch, then need to hand those bytes into the HTTP/1 parser without re-reading. Bytes already in the buffer are consumed by the parser before any transport read happens.

ยงErrors

Same as HttpContext::run โ€” any irrecoverably malformed or noncompliant HTTP/1 request surfaces as an Error.