Permalink
Browse files

MDL-31558 add missing mimetype to send_temp_file()

backported from master
  • Loading branch information...
1 parent 4886142 commit ce4126c7a9e07dd0514f7ac297b5e60cad0b8d20 @skodak skodak committed May 10, 2012
Showing with 14 additions and 0 deletions.
  1. +14 −0 lib/filelib.php
View
@@ -1626,6 +1626,13 @@ function prepare_file_content_sending() {
function send_temp_file($path, $filename, $pathisstring=false) {
global $CFG;
+ if (check_browser_version('Firefox', '1.5')) {
+ // only FF is known to correctly save to disk before opening...
+ $mimetype = mimeinfo('type', $filename);
+ } else {
+ $mimetype = 'application/x-forcedownload';
+ }
+
// close session - not needed anymore
@session_get_instance()->write_close();
@@ -1658,6 +1665,13 @@ function send_temp_file($path, $filename, $pathisstring=false) {
}
header('Accept-Ranges: none'); // Do not allow byteserving
+ if ($mimetype === 'text/plain') {
+ // there is no encoding specified in text files, we need something consistent
+ header('Content-Type: text/plain; charset=utf-8');
+ } else {
+ header('Content-Type: '.$mimetype);
+ }
+
//flush the buffers - save memory and disable sid rewrite
// this also disables zlib compression
prepare_file_content_sending();

0 comments on commit ce4126c

Please sign in to comment.