This is an odd issue, and I can’t see why it would be ColdBox/ContentBox related, except that I can’t reproduce it outside of them, so… shrug
We have an application using a modified version of ContentBox on ColdBox 3.8.1 and the media serving is broken, possibly as a result of being on ColdFusion 11. (It was definitely working on ColdFusion 10, but the code doesn’t run on CF10 anymore so I can’t confirm if that’s a factor. It’s also not possible to run the application without IIS being involved, so I can’t entirely rule that out either.)
The issue is that having a query string is somehow corrupting the response for a cfcontent - I don’t know whether this is being done by the app or by CF/Tomcat/IIS, but instead of a 767KB JPG it is returning a 1320 byte file which starts with a JPG magic number (first four bytes) and then completely different data, causing Firefox to complain:
the image … cannot be displayed because it contains errors.
To re-iterate, using the exact same code, requesting this URL works:
http://localdomain/__media/Jellyfish.jpg
Whilst this returns the invalid data:
http://localdomain/__media/Jellyfish.jpg?nocache=12345
Any non-empty querystring will do it. It occurs with other files and on another server (both with CF11 update 2).
The code serving the image is from ContentBox:
https://github.com/Ortus-Solutions/ContentBox/blob/master/modules/contentbox-ui/handlers/media.cfc
deliverMedia - https://github.com/Ortus-Solutions/ContentBox/blob/master/modules/contentbox/model/media/CFContentMediaProvider.cfc
sendFile - https://github.com/Ortus-Solutions/ContentBox/blob/master/coldbox/system/core/util/FileUtils.cfc
I have tried updating the media handler to just do the following after line 43:
var realPath = mediaService.getCoreMediaRoot( absolute=true ) & “/#prc.mediaPath#”;
cfcontent( reset=true , file=realPath );abort;
The issue still occurs using that code, which is what makes me think CF11 is at fault - there’s no code that should interfere or differentiate between QS/non-QS.
It’s not just the media handler, it seems to also happen for filebrowser’s download handler (which uses fileutils.sendFile), i.e this also gives the corrupt image: http://localdomain/cbFileBrowser/download?path=/Jellyfish.jpg
If I instead use http://localdomain/othershowoff.dev/cbFileBrowser/download/path/%2FJellyfish.jpg it returns the correct file, and likewise if I hardcode the path in the download function and remove the QS then it sends the correct file, so it is having url parameters or a querystring that cause the problem, but I can’t figure it out beyond that.
I’ve copied the FileUtils sendFile function into a standalone file and it works fine there - QS or not the correct file is returned, whether going direct to CF11 or via IIS.
So yeah, if I’m missing something obvious or someone has encountered this before that’d be great to know, but if nothing else this will get indexed by search engines in case someone else has the same problem…