diff --git a/NEWS b/NEWS index cc76b028..e3ee2d7c 100644 --- a/NEWS +++ b/NEWS @@ -53,7 +53,6 @@ NEWS * Add support for "real" entropy from /dev/[u]random (fixes #1977) * Adding support for additional chars in LDAP usernames (fixes #1941) * Ignore multiple "If-None-Match" headers (only use first one, fixes #753) - * Add X-Sendfile-Range feature (fixes #2005) * Fix 100% cpu usage if time() < 0 (thx to gaspa and cate, fixes #1964) * Allow max-keep-alive-requests to depend on conditional (fixes #1881) * Make dependency on svnversion/git optional (for devel versionstamp, fixes #2009) diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c index 83cae360..0fbfebf5 100644 --- a/src/mod_fastcgi.c +++ b/src/mod_fastcgi.c @@ -2554,51 +2554,22 @@ static int fcgi_demux_response(server *srv, handler_ctx *hctx) { stat_cache_entry *sce; if (HANDLER_ERROR != stat_cache_get_entry(srv, con, ds->value, &sce)) { - data_string *dcls, *dsr; - off_t start = 0, end = sce->st.st_size, len; + data_string *dcls; if (NULL == (dcls = (data_string *)array_get_unused_element(con->response.headers, TYPE_STRING))) { dcls = data_response_init(); } /* found */ - /* Assume we should serve from the beginning to the end of the file. */ - /* If they gave us X-Sendfile-Range, adjust portion to serve. */ - /* X-Sendfile-Range: header must include start offset, may include end offset, must end after the last offset */ - if (NULL != (dsr = (data_string *) array_get_element(con->response.headers, "X-Sendfile-Range"))) { - char *end_part = NULL, *final_part = NULL; - start = strtoll(dsr->value->ptr, &end_part, 10); - if (start < 0 || end_part == ds->value->ptr) { - start = 0; - log_error_write(srv, __FILE__, __LINE__, "sb", - "Invalid X-Sendfile-Range header:", - dsr->value); - } else if (end_part && *end_part) { - end = strtoll(end_part, &final_part, 10); - if (end < 0 || end_part == final_part || !final_part || *final_part || start > end) { - start = 0; - end = sce->st.st_size; - log_error_write(srv, __FILE__, __LINE__, "sb", - "Invalid X-Sendfile-Range header:", - dsr->value); - } else { - if (end > sce->st.st_size) end = sce->st.st_size; - if (start > end) start = end; - } - } else { - if (start > end) start = end; - } - } - len = end - start; - if (len != 0) http_chunk_append_file(srv, con, ds->value, start, len); + 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, CONST_STR_LEN("Content-Length")); - buffer_copy_off_t(dcls->value, len); + buffer_copy_string_len(dcls->key, "Content-Length", sizeof("Content-Length")-1); + buffer_copy_off_t(dcls->value, sce->st.st_size); 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 = len; + 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:", diff --git a/src/response.c b/src/response.c index bf3650f3..ae9aeff2 100644 --- a/src/response.c +++ b/src/response.c @@ -70,7 +70,7 @@ int http_response_write_header(server *srv, connection *con) { if (ds->value->used && ds->key->used && 0 != strncasecmp(ds->key->ptr, CONST_STR_LEN("X-LIGHTTPD-")) && - 0 != strncasecmp(ds->key->ptr, CONST_STR_LEN("X-Sendfile"))) { + 0 != strcasecmp(ds->key->ptr, "X-Sendfile")) { if (0 == strcasecmp(ds->key->ptr, "Date")) have_date = 1; if (0 == strcasecmp(ds->key->ptr, "Server")) have_server = 1; if (0 == strcasecmp(ds->key->ptr, "Content-Encoding") && 304 == con->http_status) continue; diff --git a/tests/docroot/www/sendfile.php b/tests/docroot/www/sendfile.php deleted file mode 100644 index ecdd7125..00000000 --- a/tests/docroot/www/sendfile.php +++ /dev/null @@ -1,7 +0,0 @@ - \ No newline at end of file diff --git a/tests/lighttpd.conf b/tests/lighttpd.conf index e2fd96a7..b4a90c4e 100644 --- a/tests/lighttpd.conf +++ b/tests/lighttpd.conf @@ -82,7 +82,7 @@ $HTTP["url"] =~ "\.pdf$" { } fastcgi.debug = 0 -fastcgi.server = ( ".php" => ( ( "host" => "127.0.0.1", "port" => 1026, "broken-scriptfilename" => "enable", "allow-x-send-file" => "enable" ) ), +fastcgi.server = ( ".php" => ( ( "host" => "127.0.0.1", "port" => 1026, "broken-scriptfilename" => "enable" ) ), "/prefix.fcgi" => ( ( "host" => "127.0.0.1", "port" => 1026, "check-local" => "disable", "broken-scriptfilename" => "enable" ) ) ) diff --git a/tests/mod-fastcgi.t b/tests/mod-fastcgi.t index 8fc35e1d..b5f74d64 100755 --- a/tests/mod-fastcgi.t +++ b/tests/mod-fastcgi.t @@ -7,7 +7,7 @@ BEGIN { } use strict; -use Test::More tests => 55; +use Test::More tests => 53; use LightyTest; my $tf = LightyTest->new(); @@ -25,7 +25,7 @@ SKIP: { } SKIP: { - skip "no PHP running on port 1026", 32 unless $tf->listening_on(1026); + skip "no PHP running on port 1026", 30 unless $tf->listening_on(1026); ok($tf->start_proc == 0, "Starting lighttpd") or goto cleanup; @@ -174,20 +174,6 @@ EOF $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/foo/bar' } ]; ok($tf->handle_http($t) == 0, 'PATH_INFO, check-local off'); - $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Length' => 4348 } ]; - ok($tf->handle_http($t) == 0, 'X-Sendfile'); - - $t->{REQUEST} = ( <{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'OCTYPE ' } ]; - ok($tf->handle_http($t) == 0, 'X-Sendfile-Range'); - ok($tf->stop_proc == 0, "Stopping lighttpd");