While you can't modify any old header in the Truclient script, you can modify the user-agent in the header. This function will modify the user-agent string programatically. It accesses the property that is available in the Runtime settings, however you can use this function to change the value dynamically in the script.
function setUserAgent(value) {
var prefs = Components.classes[''@mozilla.org/preferences-service;1''].getService(Components.interfaces.nsIPrefService);
var uaPref = prefs.getBranch(''general.useragent.'');
if (value)
uaPref.setCharPref(''override'', value);
else
uaPref.clearUserPref(''override'');
}
How do you call the function:
Add an Eval JS step to your script in Develop mode. In the step argument add this code:
setUserAgent(''**HELLO-WORLD**'');
The result is:
Running Vuser...
Starting iteration 1.
Starting action Action.
t=00009157ms: New User Started [MsgId: MMSG-205200]
t=00009634ms: ** 1: Evaluate JS setUserAgent(''HELLO-WORLD''); ** started [MsgId: MMSG-204251]
t=00009804ms: ** 1: Evaluate JS setUserAgent(''HELLO-WORLD''); ** successfully completed [MsgId: MMSG-204250]
t=00010268ms: ** 2: Navigate to ''www.amazon.com'' ** started [MsgId: MMSG-204251]
t=00010652ms: Request headers for ''http://www.amazon.com/'' (internal ID=1, 291 byte(s)) [MsgId: MMSG-204899]
GET / HTTP/1.1
Host: www.amazon.com
User-Agent: **HELLO-WORLD**
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Where do I put the function definition?
Paste the code just as it appears above into the JS-functions.js file in the main VUGEN window.