_resumable_download_download currently uses module_invoke_all to invoke all instances of hook_file_download. As documented in the comments in file_download in file.inc, module_invoke_all will use array_merge_recursive instead of array_merge, and if more than one module implements this hook, this can result in incorrect header data - for example, trying to pass an array for "content-type" instead of a single value, which happens to cause Chrome's built in PDF reader to choke (which is what caused me to discover the issue). _resumable_download_download should instead manually loop thru invoking hook_file_download for all modules that implement it and use array_merge instead of array_merge_recursive (just as file_download does).

Comments

olarin’s picture

Patch to do that thing I just said.

olarin’s picture

Status: Active » Needs review
sinasalek’s picture

Tx Olarin, i'll test and commit your patch

olarin’s picture

The code from core that this duplicates has been abstracted out into a helper function in the latest version of core - file_download_headers() - so we might want to change this patch to call that helper function now rather than duplicate its code.

ñull’s picture

Patch for the related issue uses this helper function as a fix.

sinasalek’s picture

Thanks for clarification, will be committed alongside the related issue

olarin’s picture

This new version of the patch should be functionally identical to the last one, but takes advantage of the file_download_headers() function that has since been added to core (which basically just encapsulates the exact code I copy-pasted from core in the first place).

olarin’s picture

Argh, I seem to have done something with the patch file in 7 that made drush make not want to apply it (some kind of whitespace issue maybe?), let's try that again.

bohus ulrych’s picture

StatusFileSize
new2.09 KB
new39.54 KB
new10.02 KB
new6.22 KB

Hi all,
thank you all for helping me to solve my issue - patch #8 works great. Without this module I was not able too seek in the video in Chrome.

Maybe it would worth to create new module version with this patch included, it took me few hours to realize that my issue is related to this topic. Title "resumable_download should mimick core file module in avoiding module_invoke_all" doesn't help too much.

In my case I hade these symptoms of the duplicated headers - see more on screenshots:
1 - video file was not played in Internet explorer (IE11) because of "MEDIA12899: AUDIO/VIDEO: Unknown MIME type"
2 - PDF was not rendered in the Chrome's PDF reader "Failed to load PDF document"
(both private files, after applying patch works like charm)
Hopefully these keywords can save time to someone.

sinasalek’s picture

Status: Needs review » Fixed

NOTICE: I only applied the patches, i have not been able to test it, if someone confirm that everything works properly i can create a new release
https://www.drupal.org/project/resumable_download/releases/7.x-1.x-dev

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.