Esente
Esente
DDeno
Created by Esente on 3/20/2024 in #help
How to know when a Deno.Conn is closed
A Deno.Conn is created either with Deno.connectTls or Deno.connect. How do we detect when the connection is closed to handle appropriately? I think I can getReader from the conn's readable and use the closed promise there, but my plan is to pass along the readable so I try not to acquire a lock on that reader.
1 replies
DDeno
Created by Esente on 7/31/2023 in #help
Streaming FormData
I have Deno.serve a HTML page with <form enctype="multipart/form-data"> with a file input. I also have a handler for POST that would take that File, split it, and sends the chunks to another endpoint. What I have so far in the POST handler is to await request.formData() to retrieve the File from there and split. It works fine for small files, but for big file, the handler would wait until the whole file is sent before starting to split, which can overflow the memory. Is there a way that I can immediately stream the File from the browser's request, and split it as more data come in?
6 replies
DDeno
Created by Esente on 7/18/2023 in #help
Reuse Deno.serve for other TCP connections
Hello, As a newcommer to Deno, I wrote a client for NNTP protocol (https://github.com/sntran/deno_nntp) following the specs. In the process, I did all the reading the connection, parsing for status code and text, headers and body. As I get more acquainted with Deno, I realize that I basically re-implemented what Deno HTTP API is, of course, in a much less efficient way. I would like to ask for guideline in a way I can reuse some or most of that API to avoid the parsing. For example, we have Deno.serveHttp. If I understand it correctly, it reads the connection for HTTP message (https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages), parses into HTTP request and returns HttpConn, which yields up RequestEvent. I would like to hook on that and return custom Conn instead. NNTP connection is very similar to HTTP conn.
1 replies