Contribute Open Script

Payload inspection sample 4: substitute response payload when status code matches

by lix ‎04-02-2014 03:40 PM - edited ‎04-02-2014 03:45 PM (1,884 Views)

Tested with Brocade ServerIron ADX : Yes

Description :

if response status code matches "200", ADX will inspect the response payload content. When any words in the payload matches patterns 'In the late 1950s', 'wireless media', 'Computer networks differ in the physical media used to transmit their signals', ADX will sbstitute the matched patterns with the target words directly in the response payload. With OS_PAYLOAD_INSPECT::substitute, no extra event  will be triggered.

 

use OS_SLB;
use OS_HTTP_REQUEST;
use OS_PAYLOAD_INSPECT;

 

sub HTTP_RESPONSE {
    my $code = OS_HTTP_RESPONSE::code;

    print "Response status code: $code\n";

 

    if ( $code == 200) {
        OS_PAYLOAD_INSPECT::substitute('In the late 1950s',' ========= REPLACED Metcalfe pursued TO VERY LONG STRING FOR TESTING SERVERIRON ADX - OPEN SCRIPT PAYLOAD INSPECT API ========= ',
                                       'wireless media',' @@@ WIRED MEDIA @@@ ',
                                       'Computer networks differ in the physical media used to transmit their signals',' === CHANGED TO SMALL === ');
    }
}

 

Contributors