Skip to content

Commit

Permalink
Issue #1229014 by bfroehle, jackbravo, illmasterc: Fixed Content-Disp…
Browse files Browse the repository at this point in the history
…osition header makes private files show open/save prompts, but public files show inline.
  • Loading branch information
DavidRothstein committed Apr 1, 2013
1 parent 867ce3a commit b927d87
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

Drupal 7.22, xxxx-xx-xx (development version)
-----------------------
- Removed an unnecessary "Content-Disposition" header from private file
downloads; it prevented many private files from being viewed inline in a web
browser.
- Changed various field API functions to allow them to optionally act on a
single field within an entity (API addition: http://drupal.org/node/1825844).
- Fixed a bug which prevented Drupal's file transfer functionality from working
Expand Down
10 changes: 0 additions & 10 deletions includes/file.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2481,20 +2481,10 @@ function file_directory_temp() {
function file_get_content_headers($file) {
$name = mime_header_encode($file->filename);
$type = mime_header_encode($file->filemime);
// Serve images, text, and flash content for display rather than download.
$inline_types = variable_get('file_inline_types', array('^text/', '^image/', 'flash$'));
$disposition = 'attachment';
foreach ($inline_types as $inline_type) {
// Exclamation marks are used as delimiters to avoid escaping slashes.
if (preg_match('!' . $inline_type . '!', $file->filemime)) {
$disposition = 'inline';
}
}

return array(
'Content-Type' => $type,
'Content-Length' => $file->filesize,
'Content-Disposition' => $disposition . '; filename="' . $name . '"',
'Cache-Control' => 'private',
);
}
Expand Down
1 change: 0 additions & 1 deletion modules/image/image.test
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,6 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
// Only verify HTTP headers when using private scheme and the headers are
// sent by Drupal.
$this->assertEqual($this->drupalGetHeader('Content-Type'), 'image/png', t('Content-Type header was sent.'));
$this->assertEqual($this->drupalGetHeader('Content-Disposition'), 'inline; filename="' . $test_image->filename . '"', t('Content-Disposition header was sent.'));
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'private', t('Cache-Control header was sent.'));

// Log out and try to access the file.
Expand Down

0 comments on commit b927d87

Please sign in to comment.