--- src/mod_fastcgi.c.orig 2008-03-07 12:48:34.000000000 +0200 +++ src/mod_fastcgi.c 2008-07-31 17:29:05.000000000 +0300 @@ -2540,28 +2540,24 @@ if (host->allow_xsendfile && (NULL != (ds = (data_string *) array_get_element(con->response.headers, "X-LIGHTTPD-send-file")) - || NULL != (ds = (data_string *) array_get_element(con->response.headers, "X-Sendfile")))) { - stat_cache_entry *sce; + || NULL != (ds = (data_string *) array_get_element(con->response.headers, "X-Sendfile")))) + { + /* try to use mode->direct instead of the usual joblist */ - if (HANDLER_ERROR != stat_cache_get_entry(srv, con, ds->value, &sce)) { - data_string *dcls = data_string_init(); - /* found */ - http_chunk_append_file(srv, con, ds->value, 0, sce->st.st_size); - hctx->send_content_body = 0; /* ignore the content */ - joblist_append(srv, con); - - buffer_copy_string_len(dcls->key, "Content-Length", sizeof("Content-Length")-1); - buffer_copy_long(dcls->value, sce->st.st_size); - dcls = (data_string*) array_replace(con->response.headers, (data_unset *)dcls); - if (dcls) dcls->free((data_unset*)dcls); + fcgi_connection_close(srv, hctx); - con->parsed_response |= HTTP_CONTENT_LENGTH; - con->response.content_length = sce->st.st_size; - } else { - log_error_write(srv, __FILE__, __LINE__, "sb", - "send-file error: couldn't get stat_cache entry for:", - ds->value); - } + /* tell the server to handle this file through mod_staticfile */ + buffer_reset(con->uri.path); + buffer_reset(con->physical.path); + + buffer_copy_string(con->uri.path, ""); + buffer_copy_string_buffer(con->physical.path, ds->value); + + con->mode = DIRECT; + joblist_append(srv, con); /* in case we come from the event-handler */ + + buffer_free(packet.b); + return HANDLER_FINISHED; }