Coldfusion CFHTTP.Responseheader

标签 coldfusion coldfusion-9

我正在努力弄清楚如何读取 cfhttp.responseHeader 的内容。我正在尝试访问一个在响应中发送几个 cookie 的网站。我需要从响应中提取它们。然后将 cookie 值与所有 future 请求一起发送。我尝试使用以下代码:

<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> 

最佳答案

您可以像这样检索 cookie:

<cfset cookies = cfhttp.responseHeader["set-cookie"] />

<cfdump var="#cookies#" />

然后您可以使用该 cookie 结构数据来发出后续请求。

关于Coldfusion CFHTTP.Responseheader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11834128/

相关文章:

coldfusion - 为什么 writedump 函数不需要在 cfscript 中使用分号?

mysql - 使用 Coldfusion 将文件保存在 MySQL 中

mysql - Coldfusion中如何对mysql数据库进行加密和使用

orm - Coldfusion 9 ORM 映射问题

sql - 需要远程或基于 Web 的 MS Access SQL 工具(例如类似于 PhpMyAdmin,但基于 ColdFusion)

variables - Coldfusion 8 -> 9 更新,功能不再工作

coldfusion - 加快 QoQ 速度还是其他方法?

oracle11g - Coldfusion 9.0.1 Standard 64bit 和 Oracle 11g 64bit ODBC 连接结果为 "architecture mismatch"

coldfusion - 有没有办法将数据库中的每一行的值放入数组中?

coldfusion - 如何配置 ColdFusion Eclipse 调试器