Reopening: Stream status code

Philip Linde linde.philip at gmail.com
Fri Jul 31 12:18:58 BST 2020


On Fri, 31 Jul 2020 07:01:10 -0400
Paul Boyd <boyd.paul2 at gmail.com> wrote:
> Please don't. That would complicate generated responses. The server would
> have to hold the response until the whole thing was rendered just to count
> the number of bytes. It's a lot simpler to write the data as it's ready,
> which also avoids (potentially large) temporary memory allocations.

That is true. There are approaches to dynamically generated responses
that avoid the need for preallocation, but they are indeed quite
complex compared to having e.g. a CGI script simply dump some data on
its standard output.

Usually, when I need to determine a buffer size in advance, I implement
a "dry run" of whatever fills the buffer that instead of writing
anything simply tallies up the number of bytes that *would* be written
and run that to determine the size of the buffer before a "real" run. A
similar approach can be used to determine content length for CGI
scripts.

It's a good point nonetheless.

--
Philip
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <https://lists.orbitalfox.eu/archives/gemini/attachments/20200731/7856c218/attachment.sig>


More information about the Gemini mailing list