In the function connection_handle_write_prepare(), lines 537ff. of connections.c (rev. 1716) are as follows:
/* disable keep-alive if size-info for the body is missing */
if ((con->parsed_response & HTTP_CONTENT_LENGTH) &&
((con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) == 0)) {
con->keep_alive = 0;
}
Given the intention stated in the comment, it is likely that the condition in line 538 is reversed, and the whole should rather read:
if ((!(con->parsed_response & HTTP_CONTENT_LENGTH)) &&
((con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) == 0)) {
con->keep_alive = 0;
}
Indeed, as con->keep_alive seems to be never set back to 1 anywhere in connection_handle_write_prepare() (or elsewhere down the execution flow), lighttpd returns a Connection: close header and resets the connection even when the client sends a Connection: keep-alive request. Moreover, if an upstream handler (e.g. a process behind mod_fcgi) responds with a Connection: keep-alive header, the client gets the connection reset anyway.