I am running ColdFusion 2016 developer edition. I am using cfhttp
to test some settings on a remote Apache web server. Is there a way to set the User Agent? The default seems to be set to ColdFusion
. When I use cfhttpparam
to try to set a new value:
<cfhttpparam type="header" name="user-agent" value="Test UA">
this new value simply gets added and I get:
"ColdFusion, Test UA"
NOTE: I know that the user-agent
header is not a reliable measure to use as it can be changed by the user. However, both my servers are test servers and I'm running tests to help me create some settings on more reliable measures.
As hinted by @KevinB, cfhttp
has a useragent
attribute which can be used as shown below.
Here is what worked:
<cfhttp url=".." ... useragent="Test UA"> .... </cfhttp>
And the remote server sees:
"Test UA"
In cfscript
I'm able to set it this way:
httpService = new http(url="...", ...., useragent="Test UA"); //OR
httpService.setAttributes( useragent="Test UA" ); //Once httpService has been instantiated
CFHTTP Attributes
useragent String Default:
ColdFusion
Text to put in the user agent request header. Used to identify the request client software. Can make the CFML application appear to be a browser.