Project

General

Profile

[Solved] mod_cgi without local buffering

Added by bit_twiddler about 6 years ago

I have a CGI which sends data continuously (for server sent events). Unfortunately, mod_cgi writes the output from the cgi into /tmp/lighttpd-upload-* instead of directly out the network. Is there a way to tell mod_cgi to skip the chunkqueue stuff and just flush directly to the network?


Replies (7)

RE: mod_cgi without local buffering - Added by chris.h about 6 years ago

While you're fairly vague, I'm pretty sure you're talking about a "stream", and you're probably going to want to dump (pipe) it to a (UNIX) socket. Lighty already supports, and uses sockets. You can easily find the info in either the lighttpd.conf, or the documentation. I can't really comment any more specifically, because your description is so vague. Sorry.

--Chris

RE: [Solved] mod_cgi without local buffering - Added by gstrauss about 6 years ago

For response output, there is

server.stream-response-body = 1 (or 2)

For request input, there is

server.stream-request-body = 1 (or 2)

RE: [Solved] mod_cgi without local buffering - Added by bit_twiddler about 6 years ago

Let me clarify then. Consider the following cgi:

#!/bin/sh

echo "Content-Type: text/event-stream" 
echo "Cache-Control: no-cache" 
echo "" 

cnt=0

while :; do
    echo "data: $cnt" 
    cnt=$((cnt + 1))
done

echo "" 

If you were to just call this script locally, you'd get continuous output.
If you call this through lighttpd, say with a curl request, the output buffers into /tmp/lighttpd-upload-xxxxx until the cgi stops.

I will look at sockets support, if you think that's what I need to use.
server.stream-response-body doesn't seem to do what I want either.
I was hoping there was just a flag which told mod_cgi to write directly to the socket instead of buffering to /tmp.

RE: [Solved] mod_cgi without local buffering - Added by bit_twiddler about 6 years ago

gstrauss wrote:

For response output, there is

server.stream-response-body = 1 (or 2)

For request input, there is

server.stream-request-body = 1 (or 2)

It seems that mod_cgi does not pay attention to this setting

RE: [Solved] mod_cgi without local buffering - Added by bit_twiddler about 6 years ago

Aha. This was fixed somewhere between 1.4.45 and 1.4.48. With 1.4.48, output is streamed without buffering, which is what I wanted. Thanks!

RE: [Solved] mod_cgi without local buffering - Added by laoshaw about 2 months ago

using mod_cgi and streaming(server.stream-request-body=2) lighttpd still fails when my uploaded file is larger than available memory

RE: [Solved] mod_cgi without local buffering - Added by gstrauss about 2 months ago

@laoshaw: You do not seem to have grown in 6 years.
See your last post here 6 years ago: https://redmine.lighttpd.net/issues/2108#note-9

Please see How to get support - please read and do not post here again until you have grown enough to understand what that page recommends.

    (1-7/7)