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.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”transport
Section titled “transport”A stream transport not started yet.
inspect
Section titled “inspect”(received) => T | undefined
Returns the decision, or undefined to wait for more bytes.
options
Section titled “options”Returns
Section titled “Returns”Promise<PeekedTransport<T>>
The decision and the transport replaying the inspected bytes.
Throws
Section titled “Throws”When maxLength bytes arrived with no decision.
Throws
Section titled “Throws”When the peer ended or closed the connection first.
Throws
Section titled “Throws”When the transport failed or options.signal aborted. On every
failure the transport is destroyed.