Skip to content

peekTransport

peekTransport<T>(transport, inspect, options): Promise<PeekedTransport<T>>

Defined in: packages/net-core/src/peek-transport.ts:46

Look at the first bytes a stream transport receives without consuming them, to choose the protocol that will read it — as a server sniffing the HTTP/2 connection preface before choosing between HTTP/1.1 and HTTP/2.

Starts transport and calls inspect with everything received so far, after each delivery, until it returns anything but undefined.

T

Transport

A stream transport not started yet.

(received) => T | undefined

Returns the decision, or undefined to wait for more bytes.

PeekTransportOptions

Promise<PeekedTransport<T>>

The decision and the transport replaying the inspected bytes.

When maxLength bytes arrived with no decision.

When the peer ended or closed the connection first.

When the transport failed or options.signal aborted. On every failure the transport is destroyed.