tracker issue : CF-3574332

select a category, or use search below
(searches all categories and all time range)

CHTTP returns filecontent as when mimetype is application/json

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): James Moberg / James Moberg (James Moberg)

Created: 06/06/2013

Components: Net Protocols, HTTP

Versions: 9.0.1

Failure Type:

Found In Build/Fixed In Build: 9.0.1 /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Win 2008 Server R2 64 bit

Vote Count: 0

Problem Description: I'm accessing the OpenWeatherMaps API with ColdFusion 9,0,1,274733 (Java 1.6.0_29) and the data is not returned as plain text in the CFHTTP.FileContent response variable.

Steps to Reproduce:
        <cfhttp url="" method="GET">

Actual Result: CFHTTP.FileContent is "object of" instead of JSON data.  (CFHTTP.Text = "no")

Expected Result:  Usable JSON data... use your browser to open this URL:

Any Workarounds:  Use Java?   Use CFHTTP.FileContent.toString() to convert the object to a text string containing the JSON data. (This won't impact the value if FileContent is already plaintext.)

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3574332

External Customer Info:
External Company:  
External Customer Name: Jamo
External Customer Email:  
External Test Config: My Hardware and Environment details: ColdFusion 9,0,1,274733 (Java 1.6.0_29) on Windows Server 2008 R2  (64 bit)

NOTE: I tried this same request using CF10 and it return a text JSON string instead of an object.



Do issues regarding "CFHTTP" belong in the "Core Runtime" product area? (I'm never sure how to categories issues that I report.)
Comment by External U.
15240 | June 06, 2013 01:37:49 PM GMT
Sorry... the API URL should be: (I forgot the parameter "q" and can't edit my submission.)
Comment by External U.
15241 | June 06, 2013 01:42:38 PM GMT
If the mode is XML and returned mime type is "text/xml", then CFHTTP.FileContent is a text string:
Comment by External U.
15242 | June 06, 2013 01:46:49 PM GMT
If you set getasbinary="never" on the CFHTTP call, it'll not convert the JSON to a ByteArrayOutputStream. Still: it should simply not be messing with it anyhow. -- Adam
Comment by External U.
15243 | June 14, 2013 02:17:40 AM GMT
This was fixed in CF 10.
Comment by Himavanth R.
15244 | October 30, 2013 09:11:55 AM GMT
I fully understand that it was fixed in ColdFusion 10. I specifically reported it as a ColdFusion 9 bug almost 6 months ago hoping that it would get fixed. It looks like the default option is "no" (if ColdFusion does not recognize the response body type as text, converts it to a ColdFusion object), but it looks like the rules for identifying what "text" is is rather narrow: - the header does not specify a content type. - the content type starts with "text". - the content type starts with "message". - the content type is "application/octet-stream". ColdFusion 9 CFHTTP (getAsBinary) ColdFusion 10 CFHTTP (getAsBinary) Can the definition of "text" in ColdFusion 9 be expanded to include "application/json" and "application/x-javascript"? I noticed that it works in ColdFusion 10 without passing "getasbinary" even though the header response doesn't meet the criteria. The MIME type "application/x-javascript" doesn't work in ColdFusion 10. "application/json" must have a special exemption rule and javascript should be added to that filter. ColdFusion 9 and 10 apparently both share the same exact rules regarding "getasbinary" but are not consistent in how the rules are applied. (NOTE: If this has been fixed in ColdFusion 10, it should definitely be fixed in ColdFusion 9.)
Comment by External U.
15245 | October 31, 2013 09:59:00 AM GMT
@Jamo, If you need an urgent fix for this bug CF 9.0.x, I would recommend you to get in touch with the support.
Comment by Rupesh K.
15246 | November 02, 2013 03:48:51 PM GMT
Regarding my comments, will the status of this ColdFusion 9 bug be updated and would it be included in any future patches? (Are there any future patches for CF9 planned at all?) Will ColdFusion 10 documentation be updated since "application/json" (and add support for "application/x-javascript") doesn't match the documented rules? Will these changes be identified and made in CF11 or will they need to be re-reported after release?
Comment by External U.
15247 | November 03, 2013 10:16:41 AM GMT