Hi all,
in the example below both $URLretrevd and $retrievedHH have the $path ...
Why?
Any workaround?
Thanks!
$rule_state = rule.getstate();
if ($rule_state == "REQUEST"){
$Req_client_ip = request.getRemoteIP();
$ReqOrihh = http.getHostHeader();
$path = http.getPath();
$Reqheaders = http.getHeaders();
foreach( $header in hash.keys( $Reqheaders ) ) {
if ($header == "X-Forwarded-For") {
$ReqXForwardedFor = ($Reqheaders[$header]);
data.set( $XForwardedFor, $ReqXForwardedFor );
data.set( $ReqHH, $ReqOrihh );
data.set( $URLREQ, $path);
}
}
}
if ($rule_state == "RESPONSE"){
if( http.getResponseCode() == 301 ) {
$location = http.getResponseHeader( "Location" );
$headers = http.getResponseHeader( "OriginalHost" );
$Resheaders = http.getHeaders();
$retrievedIP = data.get( $XForwardedFor );
$URLretrevd = data.get( $URLREQ );
$retrievedHH = data.get( $Reqhh );
foreach( $header in hash.keys( $Resheaders ) ) {
if ($header == "X-Forwarded-For") {
$ResXForwardedFor = ($Resheaders[$header]);
if ( $ResXForwardedFor = $retrievedIP ) {
log.info( "JP - " . " req HH URL : " . $retrievedHH . $URLretrevd );
}
}
}
}
Solved! Go to Solution.
fixed by appending the variables on the data.set
data.set( $REQqs, $ReqOrihh.$path.$qs);
more info on the behaviour
ex (code omitted see above for full):
data.set( $XForwardedFor, $ReqXForwardedFor );
data.set( $ReqHH, $ReqOrihh );
data.set( $URLREQ, $path);
data.set( $REQqs, $qs);
$retrievedIP = data.get( $XForwardedFor );
$URLretrevd = data.get( $URLREQ );
$retrievedHH = data.get( $Reqhh );
$retrievedQS = data.get( $REQqs );
log.info( "JP - " . " req HH URL : " . "hh : " . $retrievedHH . "url : " . $URLretrevd . "qs : " . $retrievedQS );
this will only print the query string output on all the variables. ex:
JP - req HH URL : hh : campaign=FavIE_v1url : campaign=FavIE_v1qs : campaign=FavIE_v1
Glad you managed to find your problem and bonus points for updating your Q with the answer!
As an aside, when you are posting TS, did you know we have TS syntax highlighting available?
I have set up a doc here: (Posting TrafficScript to Splash with Syntax Highlighting) that shows how...
Cheers..
Aidan.