![]() |
Non-parsed headers?
Hi, I'm trying to use LiteSpeed to generate x-mixed-replace content via a FastCGI responder.
Using `strace(1)', I can see that my application is sending the response to LSWS and flushing completely. However, LSWS is not flushing the response to the client as the individual parts are received. Note: the response I am sending to LSWS has been piped through "cat -vent" to show the control characters used. Code:
1 HTTP/1.0 200 OK^M$ |
I think your fast CGI responder does not fully comply with fast CGI specification. LSWS buffers response until "FCGI_END_REQUEST" packet is received for such a small response body. I believe, LSWS does not receive "FCGI_END_REQUEST" in your case.
In order to help debuging the problem, you can turn on LSWS debug log by setting debug level to "HIGH" from the web admin interface. What language is being used? Are you using any Fast CGI SDK or implementing the Fast CGI protocol stack yourself? |
Quote:
Apache handles this by turning off buffering if the script issues a complete HTTP compliant header (including the response code line) - see http://httpd.apache.org/docs/misc/FA...ml#nph-scripts. FYI, I'm using Perl's FCGI module. Code:
2004-06-29 14:27:16.117 [DEBUG] [192.168.1.30:40428-1] Keep-alive timeout, close!Code:
2004-06-29 14:27:27.919 [DEBUG] [192.168.1.30:40430-0:fcgi] ExtConn::onRead() |
I see.
The NPH feature will be supported in next release. We buffer the response for the following reasons, to determine whether to compress the response, to maximize the compression ratio, to avoid TCP packet fragmentations, etc. And, if the response fragment is big enough, it will be sent to client immediately. In some cases, unbuffered might be preferred. However, the log shows that the output is still buffered on the fast CGI side. Thank you for the detail explanation. :-) George |
Yes, there are lots of good reasons to buffer.
An alternative to going down the nph vs normal mode might be to simply use Nagle's algorithm (flush output buffer if it is full, or if there was N ms of inactivity). This is of course really simple to implement in userspace threaded / event based programs. A tunable Nagle buffer would be the most flexible solution. Set it to 0ms for unbuffered behaviour, or to 100ms to avoid fragmentation. I guess this would be a setting for external applications. When the response is closed, the buffer is immediately flushed of course. Then, using "nph" wouldn't be so fiddly. Deciding whether to buffer output based on whether a full HTTP header was output by the script is, after all, a horrid hack, typical of Apache! :-) |
Yes, it is simple to use Nagle's algorithm in some cases, however, it will degrade server performance if not being used wisely, we do not want to open another can of worm here. Thank you for the suggestion any way. :-)
It is trivial for us to implement the "nph" feature as every thing required is there already. I agree with you that "nph" hack is not a good thing, instead, we can easily add a configuration entry to control the buffered/unbuffered behavior for any request, but it is not bad idea to has an Apache compatible mode. |
Quote:
|
Please try release 1.5.5
|
Excellent! Here's a test program.
Quote:
Code:
#!/usr/bin/perl |
| All times are GMT -7. The time now is 07:13 PM. |