July 8, 2015 |

We’ve long had ColdFusion cfm pages that fetch images from a remote server using cfhttp or the local file system and serve them to the client web browser using a combination of the cfcontent, cfheader and cfoutput tags. As we move our production version of ColdFusion from version 9 running on Windows Server 2008 R2/IIS 7 to version 11 running on Windows Server 2012 R2/IIS 8.5, this image serving inexplicably broke.

The symptom in the browser was that the image would not show–it would be the browser’s broken image icon instead. To begin diagnosing the issue, I loaded the cfm script directly that was serving the image. Again, the broken image icon displayed. I then began reviewing the http headers to see if anything was amiss. Both the request and response headers looked fine. The Content-Type showed “image/jpg” and the Content-Length was sufficiently large. As I dug in and compared the working version and the non-working version, one thing stuck out–the Content-Type on the non-working version added “;charset=UTF-8” to the mime type, whereas the working version omitted the charset completely. Here is a visual of what I am describing:

Working version (CF 9);


Non-working version (CF 11);


In addition, comparing the file sizes being returned by inspecting the “Size” column in Chrome’s Developer Tools view, I noticed a dramatic difference. The working version was returning 96.6 KB, while the non-working version was returning a much larger 162 KB.

Since it appeared the the charset setting was the only difference, I tried many thing to either remove it or set it to something else. But since the working version was sending it at all, I was quite unsure what the charset should be.

After trying many different charsets, including trying to remove it (didn’t work), and setting the page encoding from ColdFusion, some research finally showed that binary results should have a charset of ISO-8859-1. So I changed my cfcontent tag from this:

<cfcontent type="image/jpeg">

To this:

<cfcontent type="image/jpeg; charset=ISO-8859-1">

As soon as I made this change, the image began appearing!

In summary, it appears that ColdFusion 11 is automatically appending the charset=UTF-8 to the Content-Type header, which is a change from previous versions. To serve up binary data to the web browser, you must override that charset using the cfcontent tag and specifying the ISO-8859-1 charset instead.

Posted in:

Comments are disabled