max
max
DDeno
Created by max on 7/15/2024 in #help
Is it possible to capture console log output?
I see that console.log calls out to core.op_print. Is it possible to patch an object so that I can capture log output? Similar to how one might patch process.stdout.write with node?
6 replies
DDeno
Created by max on 5/18/2024 in #help
Deno.serve: Is it possible to flush a streaming response?
I've been playing around with this: https://docs.deno.com/examples/http-server-streaming I am coming from Go and I'm used to having the functionality to flush the http response to the socket. Allowing lots of control over when bytes are sent over the wire (like so: https://robpike.io/) Is there any mechanism to prompt deno to write to the socket? Maybe another streaming response type? Thanks!
5 replies
DDeno
Created by max on 4/23/2024 in #help
With Deno.serveHttp marked as deprecated is there a way to run an HTTP server off of a Deno.Conn?
I have a bit of weird use-case where I want to start a listener, accept the first TCP connection (and serve HTTP to it) and then reject all future TCP connections. I have the following code:
const server = Deno.listen({
hostname: "0.0.0.0",
port: 0,
});
const conn = await server.accept();
(async () => {
// Reject all additional connections.
for await (const conn of server) {
conn.close();
}
})();
const httpConn = Deno.serveHttp(conn);
for await (const requestEvent of httpConn) {
// etc...
const server = Deno.listen({
hostname: "0.0.0.0",
port: 0,
});
const conn = await server.accept();
(async () => {
// Reject all additional connections.
for await (const conn of server) {
conn.close();
}
})();
const httpConn = Deno.serveHttp(conn);
for await (const requestEvent of httpConn) {
// etc...
Is there a way to do this using Deno.serve, or something else?
8 replies