Is it possible to send a stream of Buffers with an HTML response on Node-RED?

Viewed 183

I have created the following flow on Node-RED:

enter image description here

[{"id":"6f429f2902eff7e3","type":"http in","z":"0a916e7281ac9a83","name":"","url":"/page","method":"get","upload":false,"swaggerDoc":"","x":180,"y":360,"wires":[["18ce8fb90a81c88d"]]},{"id":"2d2251b59a8f647b","type":"http response","z":"0a916e7281ac9a83","name":"","statusCode":"","headers":{"content-type":"text/html"},"x":670,"y":360,"wires":[]},{"id":"18ce8fb90a81c88d","type":"file in","z":"0a916e7281ac9a83","name":"","filename":"/home/user/page.html","format":"stream","chunk":false,"sendError":false,"encoding":"none","allProps":true,"x":420,"y":360,"wires":[["2d2251b59a8f647b"]]}]

Let's say that page.html is a huge HTML file (over 100MB)... I'd like to make this flow work in a way that I don't have to put this data on my flow at once, so I tried to make it work on a stream of buffers as the following:

enter image description here

I've also set the Content-type to text/html on the response node. But if I try to load this page on http://localhost:1880/page... My page doesn't load as expected. Is it possible to do? To send an entire webpage to the client as a stream of buffers just so I don't spend too much RAM memory on my server?

1 Answers

No, the http-in/http-response nodes do not support HTTP Chunked encoding (which is what would be needed to make this work).

If you would like to implement such a feature, bring it up on the Discourse forum or in Slack to discuss it before raising a PR against the project on GitHub.

I won't comment on how a 100mb HTML file is a bad idea in general.

Related