Project

General

Profile

Can lighttpd support multipart chunked data (from cgi/fcgi) and how?

Added by savages over 14 years ago

I have a application written in python running on apache/mod_python. I would like to port it to lighttpd. I know the fcgi 1.0 spec does NOT support multipart chunked data( it expects/generates a content_length). I need a multipart chunked data from a script, can it be done? is there a template that I can follow?

shaun


Replies (10)

RE: Can lighttpd support multipart chunked data (from cgi/fcgi) and how? - Added by Olaf-van-der-Spek over 14 years ago

Are you talking about input (request) or output (response)?

RE: Can lighttpd support multipart chunked data (from cgi/fcgi) and how? - Added by savages over 14 years ago

output request, "server push", being able to send chunks of data to the client.

RE: Can lighttpd support multipart chunked data (from cgi/fcgi) and how? - Added by Olaf-van-der-Spek over 14 years ago

Lighttpd buffers the entire response, so that's not supported.

RE: Can lighttpd support multipart chunked data (from cgi/fcgi) and how? - Added by savages over 14 years ago

using fastcgi+flup+python works

def timetick():
for i in range(0,5):
st = "--mmxtick\n"
st = "Content-Type: text/plain\n\n"
st += str(i)
"\n"
yield st
time.sleep(0)
time.sleep(1)
yield "--mmxtick--"

def pcapp(environ, start_response):
write = start_response('200 OK', [('Content-Type', 'multipart/x-mixed-replace;boundary="mmxtick"')])
return timetick()

RE: Can lighttpd support multipart chunked data (from cgi/fcgi) and how? - Added by rblon over 14 years ago

Olaf-van-der-Spek wrote:

Lighttpd buffers the entire response, so that's not supported.

Without knowing the ins-and-outs of Lighttpd, that statement doesn't seem true.
Using FCGX_FFlush (fcgi in C) I am able to send out a multi-chunked response

RE: Can lighttpd support multipart chunked data (from cgi/fcgi) and how? - Added by savages over 14 years ago

I started to read the FCGI spec(http://www.python.org/dev/peps/pep-0333/). and it stated that

"The start_response callable must return a write(body_data) callable that takes one positional parameter: a string to be written as part of the HTTP response body. (Note: the write() callable is provided only to support certain existing frameworks' imperative output APIs; it should not be used by new applications or frameworks if it can be avoided. See the Buffering and Streaming section for more details.)"

Then I found an example at http://archimedeanco.com/wsgi-tutorial/

When I asked the question I did not know but after playing with it for a day I found the answer.

RE: Can lighttpd support multipart chunked data (from cgi/fcgi) and how? - Added by rblon over 14 years ago

savages wrote:

When I asked the question I did not know but after playing with it for a day I found the answer.

Just for my understanding: what is the answer to your question??
Olav-van-der-Spek sounded pretty sure Lighttpd does not support multipart chunked data, while to me it seems Lighttpd does.

RE: Can lighttpd support multipart chunked data (from cgi/fcgi) and how? - Added by Olaf-van-der-Spek over 14 years ago

rblon wrote:

Olaf-van-der-Spek wrote:

Lighttpd buffers the entire response, so that's not supported.

Without knowing the ins-and-outs of Lighttpd, that statement doesn't seem true.
Using FCGX_FFlush (fcgi in C) I am able to send out a multi-chunked response

Hmm, are we talking about 1.4 or 1.5?
I was talking about 1.4.

RE: Can lighttpd support multipart chunked data (from cgi/fcgi) and how? - Added by rblon over 14 years ago

Me too, I'm using 1.4.23
As a test I used a simple fcgi program that
  • copies text1 to the output stream
  • flushes it
  • sleeps
  • copies text2 to the output stream
  • finishes the request
    Lighttpd returns first text1 and then (after sleep ended) text2, which suggests it is possible to send chunks of data.
    (1-10/10)