我正在努力弄清楚如何閱讀cfhttp.responseHeader
的內容。我試圖訪問一個網站,在響應中發送一些cookie。我需要從響應中提取它們。然後發送所有未來請求的cookie值。我試圖用下面的代碼:Coldfusion CFHTTP.Responseheader
<cfloop collection = #cfhttp.responseHeader# item = "httpHeader">
<cfset value = cfhttp.responseHeader[httpHeader]>
<cfif IsSimpleValue(value)>
<cfoutput>
#httpHeader# : #value#<BR>
</cfoutput>
<cfelse>
<cfloop index = "counter" from = 1 to = #ArrayLen(value)#>
<cfoutput>
#httpHeader# : #value[counter]#<BR>
</cfoutput>
</cfloop>
</cfif>
但是,這引發以下錯誤
Object of type class coldfusion.util.FastHashtable cannot be used as an array
The error occurred in C:/inetpub/wwwroot/cfdocs/Response.cfm: line 22
20 : </cfoutput>
21 : <cfelse>
22 : <cfloop index = "counter" from = 1 to = #ArrayLen(value)#>
23 : <cfoutput>
24 : #httpHeader# : #value[counter]#<BR>