Reading a ReadabeStream without consuming it?
Hi,
I'm trying to migrate an HTTP/HTTPS proxy protocol server from Node.js to Deno.
The proxy listens for TCP connections, and I need to handle HTTP and HTTPS connections differently, so the first think I do is to read the first byte of every new connection to determine if it starts with "22" (which means that it is a TLS handshake).
If it is a TLS handshake I handle that one way, else i just pass it to an HTTP parser.
The problem is that If i read the first byte then I cant pass the connection to
Deno.serveHttp
(?) because the first chunk was consumed already.
Is it possible to "peek" into a Deno.Conn / ReadableStream without consuming it, so that the Conn instance can be used elsewhere?3 Replies