Currently there is no way of modifying file_download file headers, you can only supply them and overwrite previous ones (in no specific order, unless you deliberately make sure your module is first or last in the module order).
This arose as an issue because Chrome currently has a bug which means that images can be displayed for a second and then vanish.
http://www.google.com/support/forum/p/Chrome/thread?tid=1d825178248ab136...
The solution is to remove the Content-Length which can only be achieved by weighting a module as very heavy and inserting a Content-Length => NULL array.
However this Chrome bug aside what we need is a drupal_alter() for $headers.
The attached patch adds drupal_alter('file_download_headers', $headers, $uri) to the file_download function.
| Comment | File | Size | Author |
|---|---|---|---|
| file_download_alter_headers.patch | 440 bytes | adaddinsane |
Comments
Comment #1
bfroehle commentedComment #5
mile23Drupal 8.3.x has
hook_file_download()which allows you to return headers which are merged with other implementations: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21File%21fi...It might be a similar race condition problem in that different hooks execute arbitrarily.
This hook is invoked by
FileDownloadController, which means you can also listen forKernelEvents::RESPONSEwith an appropriately-weighted listener in order to modify headers: https://www.drupal.org/node/2549159 and https://www.drupal.org/node/2047751Closing this as outdated, since the patch is for Drupal 7. Please re-open if there is still an issue.