beautypg.com

Return values, Examples – Brocade Virtual ADX OpenScript API Guide (Supporting ADX v03.1.00) User Manual

Page 126

background image

114

Brocade Virtual ADX OpenScript API Guide

53-1003243-01

Methods

9

Return values

None

Examples

In the following example, when the response content type is text, the script replaces all of the
"correct" strings with the "valid" string in the response payload.

mstr3

string

The string to match. The string can be a fixed length only with a
maximum length of 128 bytes.

rstr3

string

The replacement string for the mstr3 matched string. The string can
be a fixed length only with a maximum length of 128 bytes.

TABLE 132

Input values (Continued)

Name

Type

Description

use OS_HTTP_REQUEST;

use OS_PAYLOAD_INSPECT;

sub HTTP_REQUEST {

if (OS_HTTP_REQUEST::url =~ /login/) {

OS_PAYLOAD_INSPECT::match(

‘gold_member’,

‘basic_member’,

‘visitor’

);

}

}

sub PAYLOAD_INSPECT_MATCHED {

OS_PAYLOAD_INSPECT::matched_replace(

‘login.php’, ‘gold_login.php’,

‘login.php’, ‘basic_login.php’,

‘login.php’, ‘no_login.php’

);

}

use OS_PAYLOAD_INSPECT;

use OS_HTTP_RESPONSE;

sub HTTP_RESPONSE {

my $type = OS_HTTP_RESPONSE::content_type;

if (OS_HTTP_RESPONSE::content_type =~ /text/) {

OS_PAYLOAD_INSPECT::match("correct");

}

}

sub PAYLOAD_INSPECT_MATCHED {

OS_PAYLOAD_INSPECT::matched_replace("","valid");

}