While implementing the under-the-hood work to make Express work in Azle, chunked responses that use the response header Transfer-Encoding: chunked simply break. I will poste the actual error once I’m at my computer, but it comes from the Rust hyper library and says essentially that an unexpected content-length header has been found.
My theory is that somewhere in the boundary node pipeline the Content-Length header is always being put into the response, even if Transfer-Encoding: chunked exists. This is incorrect, as if Transfer-Encoding: chunked exists then the Content-Length header should be omitted.
Basically in Express (and I assume in a regular Node http server as well), using res.write will create a chunked response.
We can’t support this basic functionality right now because of the described error.
We have a workaround that requires extra machinery and cycles to transform all chunked responses into normal responses before returning them, and stripping our the Transfer-Encoding header and the Content-Length header.
It would be great if the boundary node pipeline would honor Transfer-Encoding: chunked headers and Content-Length headers, and generally any headers that the canister sets. The boundary nodes should interfere as little as possible with canister HTTP functionality.
FYI I had to change Azle locally to get the error to display because we are using a workaround that converts chunked response bodies into regular response bodies to overcome the issue.