Skip to content

Commit

Permalink
Merge branch 'w22_MDL-39688_m25_etag' of git://github.com/skodak/mood…
Browse files Browse the repository at this point in the history
…le into MOODLE_25_STABLE
  • Loading branch information
danpoltawski committed May 27, 2013
2 parents 191e70c + 161be92 commit 6c16494
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/filelib.php
Expand Up @@ -2021,7 +2021,11 @@ 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());
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());
}
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) and $_SERVER['HTTP_IF_NONE_MATCH'] === $file->get_contenthash()) {
header('HTTP/1.1 304 Not Modified');
return;
Expand Down Expand Up @@ -2671,6 +2675,10 @@ 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;
Expand Down
6 changes: 6 additions & 0 deletions lib/xsendfilelib.php
Expand Up @@ -68,6 +68,12 @@ 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');
Expand Down

0 comments on commit 6c16494

Please sign in to comment.