Hacker News new | ask | show | jobs
by Matthias247 1734 days ago
To allow processing of large request and response bodies. Imagine a 1Gb PUT or GET. You don’t want to spend 1Gb RAM for handling those. And you also don’t want to wait multiple minutes to hours to have the body buffered and can actually present it to application logic.
1 comments

Not sure I follow. A reasonable framework would stream both the incoming request as well as the response. If the WASM module wants to read the whole thing into memory, it's free to do so, but you could have it process the request piecemeal. It's just reading the request from a file descriptor and writing the response to another one. Not that different when those fds are actually sockets.
Oh sorry. I misread it and thought you are asking why the request isn’t passed in complete form as an environment variable too. I guess you are asking why the request headers are not transferred via stdin too? My guess it’s just because that’s how CGI works. It prevents from having apps do the parsing work. Plus what could be passed wouldn’t be the original request anyway. If the Webserver handles http2 or http3 headers would always need to be repacked into a format that the script understands.