<- back
Set session color:

// Paint a specific host red and bold
if (oSession.host == "r.codeandtest.org") {
    oSession["ui-color"] = "red";
    oSession["ui-bold"] = "1";
}

// Paint blue if host contains something and something else
if (oSession.host.Contains("code") && oSession.host.Contains("andtest")) {
    oSession["ui-color"] = "blue";
}

// Paint green if uri contains something or something else
if (oSession.uriContains("myText") || oSession.uriContains("somethingElse")) {
    oSession["ui-color"] = "blue";
}
			

Set response code:

if (oSession.uriContains("/api/page1")) {
	oSession.responseCode = 200;
}
			

Change body:

if (oSession.uriContains("/api/page2")) {
	oSession.utilDecodeResponse(); // decodes if https
	var oBody = '{"code":"ohai"}'; // sets a new variable
	oSession.utilSetResponseBody(oBody); // injects new variable as response body
}
			

Delay function:

static function wait(msecs) 
{ 
	var start = new Date().getTime(); 
	var cur = start; 
	while ((cur - start) < msecs) 
	{ 
		cur = new Date().getTime(); 
	} 
}
			

Random function:

static function randInt(min, max)
{
	return Math.round(Math.random()*(max-min)+min)
}