--- x/lighttpd-1.4.23/src/mod_fastcgi.c	2009-06-19 19:22:36.000000000 +0200
+++ lighttpd-1.4.23/src/mod_fastcgi.c	2009-10-19 23:55:42.000000000 +0200
@@ -2548,12 +2548,38 @@
 					hctx->send_content_body = 0;
 				}
 
-				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")))) {
+				if (host->allow_xsendfile && NULL != (ds = (data_string *) array_get_element(con->response.headers, "X-Sendfile"))) {
 					stat_cache_entry *sce;
 
-					if (HANDLER_ERROR != stat_cache_get_entry(srv, con, ds->value, &sce)) {
+					char *newSize;
+
+					if(NULL != (newSize = strchr(ds->value->ptr, ','))) {
+
+						int size;
+
+						ds->value->used = ++newSize - ds->value->ptr;
+						ds->value->ptr[ds->value->used - 1] = '\0';
+
+						data_string *dcls;
+						if (NULL == (dcls = (data_string *)array_get_unused_element(con->response.headers, TYPE_STRING))) {
+							dcls = data_response_init();
+						}
+
+						/* found */
+						size = atoi(newSize);
+						http_chunk_append_file(srv, con, ds->value, 0, 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_string(dcls->value, newSize);
+						dcls = (data_string*) array_replace(con->response.headers, (data_unset *)dcls);
+						if (dcls) dcls->free((data_unset*)dcls);
+
+						con->parsed_response |= HTTP_CONTENT_LENGTH;
+						con->response.content_length = size;
+
+					} else if (HANDLER_ERROR != stat_cache_get_entry(srv, con, ds->value, &sce)) {
 						data_string *dcls;
 						if (NULL == (dcls = (data_string *)array_get_unused_element(con->response.headers, TYPE_STRING))) {
 							dcls = data_response_init();
