From 1cb1157809878bbfddf061d676ecc41fea17cfd7 Mon Sep 17 00:00:00 2001 From: Matteo Scaramuccia Date: Mon, 3 Jun 2013 21:41:21 +0200 Subject: [PATCH 1/2] MDL-39832 Files: Revert MDL-39688 commit, 6ce0c9ce42fa7849e67d7611a628ece51c336c5f MDL-39688 has been successful in providing a solution for the issue but further investigations done in MDL-39832 have got the evidence that the given solution is more likely a workaround. --- lib/filelib.php | 10 +--------- lib/xsendfilelib.php | 6 ------ 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/filelib.php b/lib/filelib.php index 2d9b2b393cb..1820beac83c 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -1956,11 +1956,7 @@ function readfile_accel($file, $mimetype, $accelerate) { header('Last-Modified: '. gmdate('D, d M Y H:i:s', $lastmodified) .' GMT'); if (is_object($file)) { - if (empty($_SERVER['HTTP_RANGE'])) { - // Use Etag only when not byteserving, - // is it tag of this range or whole file? - header('Etag: ' . $file->get_contenthash()); - } + header('ETag: ' . $file->get_contenthash()); if (isset($_SERVER['HTTP_IF_NONE_MATCH']) and $_SERVER['HTTP_IF_NONE_MATCH'] === $file->get_contenthash()) { header('HTTP/1.1 304 Not Modified'); return; @@ -2610,10 +2606,6 @@ function byteserving_send_file($handle, $mimetype, $ranges, $filesize) { // better turn off any kind of compression and buffering @ini_set('zlib.output_compression', 'Off'); - // Remove Etag because is is not strictly defined for byteserving, - // is it tag of this range or whole file? - header_remove('Etag'); - $chunksize = 1*(1024*1024); // 1MB chunks - must be less than 2MB! if ($handle === false) { die; diff --git a/lib/xsendfilelib.php b/lib/xsendfilelib.php index 5c254856090..3a563fd892a 100644 --- a/lib/xsendfilelib.php +++ b/lib/xsendfilelib.php @@ -68,12 +68,6 @@ function xsendfile($filepath) { } } - // Remove Etag because is is not strictly defined for byteserving, - // is it tag of this range or whole file? - if (!empty($_SERVER['HTTP_RANGE'])) { - header_remove('Etag'); - } - if ($CFG->xsendfile === 'X-LIGHTTPD-send-file') { // http://redmine.lighttpd.net/projects/lighttpd/wiki/X-LIGHTTPD-send-file says 1.4 it does not support byteserving header('Accept-Ranges: none'); From bf4a95e6a3a84b35b5a9efbe903c9c6f9523854a Mon Sep 17 00:00:00 2001 From: Matteo Scaramuccia Date: Sat, 1 Jun 2013 12:34:40 +0200 Subject: [PATCH 2/2] MDL-39832 Files: Fixed ETag format according with RFC2616. ETag must be double quoted, http://tools.ietf.org/html/rfc2616#section-3.11: entity-tag = [ weak ] opaque-tag weak = "W/" opaque-tag = quoted-string --- lib/filelib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/filelib.php b/lib/filelib.php index 1820beac83c..24aa51970af 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -1956,7 +1956,7 @@ function readfile_accel($file, $mimetype, $accelerate) { header('Last-Modified: '. gmdate('D, d M Y H:i:s', $lastmodified) .' GMT'); if (is_object($file)) { - header('ETag: ' . $file->get_contenthash()); + header('Etag: "' . $file->get_contenthash() . '"'); if (isset($_SERVER['HTTP_IF_NONE_MATCH']) and $_SERVER['HTTP_IF_NONE_MATCH'] === $file->get_contenthash()) { header('HTTP/1.1 304 Not Modified'); return;