Broken content type

13 July 2007 00:07 (EST)
I’ve got an odd problem with CFMX server (at least version 7.0.1) recently — it looks like DateFormat function reset content type to text/html despite use of cfcontent tag for defining different mime type before.

See few short examples below:

<cfsetting enablecfoutputonly="true">

<cfcontent type="application/rss+xml; charset=utf-8">

<cfoutput><?xml version="1.0" encoding="utf-8"?>
<date>#dateformat(now())#</date>
</cfoutput>

Suddenly script returns text/html mime type instead of application/rss+xml as well as code below:

<cfsetting enablecfoutputonly="true">

<cfcontent type="application/rss+xml; charset=utf-8">
<cfset xmldate = dateformat(now()) />

<cfoutput><?xml version="1.0" encoding="utf-8"?>
<date>#xmldate#</date>
</cfoutput>

But following script does return correct (application/rss+xml) mime type:

<cfsetting enablecfoutputonly="true">

<cfset xmldate = dateformat(now()) />
<cfcontent type="application/rss+xml; charset=utf-8">

<cfoutput><?xml version="1.0" encoding="utf-8"?>
<date>#xmldate#</date>
</cfoutput>

Same happens with TimeFormat function. Is there anything specific around these functions? Can someone test last two examples with their CF instances?
Tags coldfusion cfmx cfcontent mime dateformat timeformat

AddThis Social Bookmark Button

Melbourne CFUG (July) Google Search API and correct encoding

Comments

Justin: 13 July 2007 01:53 (EST)

I found that in the second example, if I removed the charset from the content type the correct mime type was returned.

In the third example, I was returned text/html until I set showdebugoutput="false" in the <cfsetting> tag, but oddly enough that setting didn't make a difference in the 2nd example.

Dmitry Yakhnov: 13 July 2007 11:12 (EST)

Thanks for your reply, at least people will be aware of this "feature" :)

Justin: 14 July 2007 05:22 (EST)

Have you thought about submitting it as a bug? FYI- I am using version 7 also.

Dmitry Yakhnov: 15 July 2007 18:52 (EST)

Will do so a bit later :)

OpenIDtracylogan.com: 6 September 2007 06:06 (EST)

Thanks for the confirmation on this; we'd found much the same thing (after *way* too long!) while attempting to write a text/xml (and UTF-8) document that could include a call to dateformat()/timeformat(). When that call was made, the text/xml content type magically became text/html.

There is good news; after a bit of testing, this bug does appear to be fixed in CF8.

Nick Johns: 03:36 (EST)

I've also had this problem, but I worked out a workaround.

Rather than never using the dateformat & timeformat functions after a cfcontent call (which would have made things very difficult), I found that by using a
<cfflush> straight after the cfcontent tag, dateformat & timeformat can no longer change the content type.

Hope this helps for those that can't upgrade to CF8 yet!

Drop a comment... don't be shy