diff --git a/includes/file.inc b/includes/file.inc index d3ac87e..c0850b5 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -2554,11 +2554,16 @@ function file_get_content_headers($file) { $name = mime_header_encode($file->filename); $type = mime_header_encode($file->filemime); - return array( + $content_headers = array( 'Content-Type' => $type, 'Content-Length' => $file->filesize, 'Cache-Control' => 'private', ); + + // Make the content headers alterable for specific situations. + drupal_alter('content_headers', $content_headers, $file); + + return $content_headers; } /** diff --git a/modules/system/system.api.php b/modules/system/system.api.php index d6cbc76..c8cf2ef 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -3049,6 +3049,23 @@ function hook_file_url_alter(&$uri) { } /** + * Controle the content headers of a file for download. + * + * This hook is called from file_get_content_headers(). + * + * This function allows altering the content headers, if you want to change, or + * remove file download headers. + * + * @param $content_headers + * The current content headers of the file, set by file_get_content_headers(). + * @param $file + * The file object. + */ +function hook_content_headers_alter(&$content_headers, $file) { + $content_headers['Content-Transfer-Encoding'] = 'binary'; +} + +/** * Check installation requirements and do status reporting. * * This hook has three closely related uses, determined by the $phase argument: