variablescoldfusioncfhttp

How to access a variable name in ColdFusion that contains a special character


For example I have the following bit of code:

<cfhttp url="FileURL" method="get" result="HTTPResult" timeout="5" />

And I want to do this:

<cfoutput>
    #HTTPResult.ResponseHeader.content-type#
</cfoutput>

However ColdFusion will see the dash - as an operator and try to subtract variables "HTTPResult.ResponseHeader.content" from "type", and neither exists. Is there a direct way to access the "content-type" variable or do I need to jump through hoops to fetch it out of the header variable?


Solution

  • HTTPResult.ResponseHeader["content-type"]