1

我正在运行 ColdFusion 2016 开发人员版。我cfhttp用来测试远程 Apache Web 服务器上的一些设置。有没有办法设置用户代理?默认值似乎设置为ColdFusion. 当我cfhttpparam尝试设置新值时:

<cfhttpparam type="header" name="user-agent" value="Test UA">

这个新值只是被添加了,我得到:

"ColdFusion, Test UA"

注意:我知道user-agent标题不是一种可靠的措施,因为它可以由用户更改。但是,我的两台服务器都是测试服务器,我正在运行测试以帮助我创建一些更可靠测量的设置。

4

1 回答 1

2

正如@KevinB 所暗示的,cfhttp有一个useragent可以使用的属性,如下所示。

这是有效的:

<cfhttp url=".." ... useragent="Test UA"> .... </cfhttp>

远程服务器看到:

"Test UA"

cfscript可以这样设置:

httpService = new http(url="...", ...., useragent="Test UA"); //OR

httpService.setAttributes( useragent="Test UA" ); //Once httpService has been instantiated

CFHTTP 属性

用户代理 字符串 默认值ColdFusion

放入用户代理请求标头的文本。用于标识请求客户端软件。可以使 CFML 应用程序看起来像一个浏览器。

https://cfdocs.org/cfhttp

于 2017-09-20T22:19:23.373 回答