Spirent Avalanche 5.46 February 29, 2024
After you ASSIGN a run-time value to a variable, use APPLY to apply the value. You can also use APPLY with the URLENC parameter to URL encode the runtime value of an applied variable.
To apply a value to a variable use the following syntax:
<APPLY variable_name>
An HTTP/HTTPS action can be any combination of one or more variables and strings. The methods, GET, POST, HEAD, PUT, and DELETE (HTTPDEL), support multiple APPLY statements in one URL.
NOTE: See the following sections for limitations and considerations: |
The following sections contain examples of various uses of the APPLY statement in HTTP Action lists.
NOTE: All examples for HTTP apply to HTTPS as well. |
NOTE: All examples for the GET method apply to HEAD as well. |
ASSIGN VARIABLE <my_host "192.168.58.1">
1 GET http://<APPLY my_host>
Result:
1 GET http://192.168.58.1/
NOTE: Since the example above applies the host field from a variable, a slash ("/") is automatically added after the host field in the URL sent to the server. |
1 GET http://<APPLY my_host>index.html
Result:
1 GET http://192.168.58.1/index.html
ASSIGN VARIABLE <my_path "download">
1 GET http://192.168.58.1/<APPLY my_path>/index.html
Result:
1 GET http://192.168.58.1/download/index.html
ASSIGN VARIABLE <my_name "user1">
1 GET http://192.168.58.1:80/download/index.html?user=<APPLY my_name>
Result:
1 GET http://192.168.58.1:80/download/index.html?user=user1
ASSIGN VARIABLE <my_user "apple">
ASSIGN VARIABLE <my_pwd "bill">
1 GET http://192.168.1.1/abc/def/index.html?user=<APPLY my_user>&password=<APPLY my_pwd>
Result:
1 GET http://192.168.1.1/abc/def/index.html?user=apple&password=bill
ASSIGN VARIABLE <my_host "192.168.1.1">
ASSIGN VARIABLE <my_path "download">
ASSIGN VARIABLE <my_file "index.html">
ASSIGN VARIABLE <my_user "apple">
ASSIGN VARIABLE <my_pwd "bill">
1 GET http://<APPLY my_host>:80/<APPLY my_path>/<APPLY my_file>?user=<APPLY my_user>&password=<APPLY my_pwd>
Result:
1 GET http://192.168.1.1:80/download/index.html?user=apple&password=bill
ASSIGN VARIABLE <my_host_port2 "192.168.1.1:80">
ASSIGN VARIABLE <my_path "path1/path2/path3">
ASSIGN VARIABLE <my_query "?emailid=abc@spirent.com&attid=abc_attid">
1 GET http://<APPLY my_host_port2>/path/<APPLY my_path>/dir1/dir2<APPLY my_query>
Result:
1 GET http://192.168.1.1:80/path/path1/path2/path3/dir1/dir2?emailid=abc@spirent.com&attid=abc_attid
ASSIGN VARIABLE <SIGNATURE_VAR "abc_signature">
ASSIGN VARIABLE <PATH "something/abc_signature/something">
ASSIGN VARIABLE <EMAILID_VAR "abc@spirent.com">
ASSIGN VARIABLE <ATTID_VAR "abc_attid">
ASSIGN VARIABLE <ATTID_VAR2 "&attid=abc_attid">
ASSIGN VARIABLE <QUERY_VAR "?emailid=abc@spirent.com&attid=abc_attid">
1 GET http://192.168.58.1/something/<APPLY SIGNATURE_VAR>/something/something?emailid=<APPLY EMAILID_VAR>&attid=<APPLY ATTID_VAR>
Result:
1 GET http://192.168.58.1/something/abc_signature/something/something?emailid=abc@spirent.com&attid=abc_attid
1 GET http://192.168.58.1/something/<APPLY SIGNATURE_VAR>/something/something?emailid=<APPLY EMAILID_VAR><APPLY ATTID_VAR2>
Result:
1 GET http://192.168.58.1/something/abc_signature/something/something?emailid=abc@spirent.com&attid=abc_attid
1 GET http://192.168.58.1/something/<APPLY SIGNATURE_VAR>/something/something<APPLY QUERY_VAR>
Result:
1 GET http://192.168.58.1/something/abc_signature/something/something?emailid=abc@spirent.com&attid=abc_attid
NOTE: The three results above are identical. |
1 GET http://192.168.58.1/<APPLY PATH>/index.html?emailid=<APPLY EMAILID_VAR><APPLY ATTID_VAR2>
Result:
1 GET http://192.168.58.1/something/abc_signature/something/index.html?emailid=abc@spirent.com&attid=abc_attid
NOTE: The example above uses slash ("/") separators in the PATH variable. Other characters, such as ":", "?", and "=", are also allowed in variables. |
ASSIGN VARIABLE <my_host "192.168.58.1">
ASSIGN VARIABLE <my_host_port "192.168.58.1:80">
ASSIGN VARIABLE <my_name "user1">
1 GET http://<APPLY my_host>/download/index.html?user=<APPLY my_name>
Result:
1 GET http://192.168.58.1/download/index.html?user=user1
1 GET http://<APPLY my_host_port>/download/index.html?user=<APPLY my_name>
Result:
1 GET http://192.168.58.1:80/download/index.html?user=user1
The following example uses variables from a forms database named FormsDB_1, which contains a list of IP addresses, such as 192.168.58.1, 192.168.58.2, etc.
ASSIGN VARIABLE <var_IP FormsDB_1.$1>
ASSIGN VARIABLE <my_path "download">
1 GET http://<APPLY var_IP>/<APPLY my_path>/index.html
Result:
1 GET http://192.168.58.1/download/index.html
1 GET http://192.168.58.2/download/index.html
.
.
.
The following example assumes that you have captured a sessionId equal to "ABCD" (e.g., by using search criteria), and saved it in the captured_session variable. It POSTs the sessionId, along with other key/value pairs, as follows:
1 POST http://10.30.7.220/ sessionId=<APPLY BODY captured_session> key1=value1 key2=value2
The resulting BODY is as follows:
POST / sessionId=ABCD&key1=value1&key2=value2
NOTE: If you use the HEADER modifier instead of BODY in the APPLY statement, then the value of captured_session is applied to the HTTP request URI. |
The following example assumes that you have captured a sessionId equal to "ABCD" (e.g., by using search criteria), and saved it in the captured_session variable. The sessionId is suffixed with "XYZ" and sent by using a POST, along with other key/value pairs, as follows:
1 POST http://10.30.7.220/ sessionId=<APPLY BODY captured_session, "XYZ"> key1=value1 key2=value2
The resulting BODY is as follows:
POST / sessionId=ABCDXYZ&key1=value1&key2=value2
The following example assumes that you have captured a sessionId equal to "ABCD" (e.g., by using search criteria), and saved it in the captured_session variable. The sessionId is prefixed with "XYZ" and sent by using a POST, along with other key/value pairs, as follows:
1 POST http://10.30.7.220/ sessionId=XYZ<APPLY BODY captured_session> key1=value1 key2=value2
The resulting BODY is as follows:
POST / sessionId=XYZABCD&key1=value1&key2=value2
ASSIGN VARIABLE <my_host_port2 "192.168.1.1:80">
ASSIGN VARIABLE <my_path "path1/path2/path3">
ASSIGN VARIABLE <my_email "abc@spirent.com">
ASSIGN VARIABLE <my_var "abc_attid">
ASSIGN VARIABLE <my_query "?emailid=abc@spirent.com&attid=abc_attid">
1 POST http://192.168.1.1/path/<APPLY my_path>/dir1/dir2?emailid=<APPLY my_email>&attid=<APPLY my_var>
Result:
1 POST http://192.168.1.1/path/path1/path2/path3/dir1/dir2?emailid=abc@spirent.com&attid=abc_attid
1 POST http://192.168.1.1/path/<APPLY my_path>/dir1/dir2<APPLY my_query>
Result:
1 POST http://192.168.1.1/path/path1/path2/path3/dir1/dir2?emailid=abc@spirent.com&attid=abc_attid
1 POST http://<APPLY my_host_port2>/path/<APPLY my_path>/dir1/dir2<APPLY my_query>
Result:
1 POST http://192.168.1.1:80/path/path1/path2/path3/dir1/dir2?emailid=abc@spirent.com&attid=abc_attid
ASSIGN VARIABLE <my_host "192.168.1.1">
ASSIGN VARIABLE <my_path "download">
ASSIGN VARIABLE <my_file "index.html">
ASSIGN VARIABLE <my_user "apple">
ASSIGN VARIABLE <my_pwd "bill">
1 POST HTTP://<APPLY my_host>:80/<APPLY my_path>/<APPLY my_file>?user=<APPLY my_user>&password=<APPLY my_pwd>
Result:
1 POST HTTP://192.168.1.1:80/download/index.html?user=apple&password=bill
The following example uses variables from a forms database named FormDB, which contains the following sample row:
192.168.1.1,path1/path2/path3,abc@spirent.com,abc_attid,abc,xyz
For this example, the following parameters are defined from the forms database columns:
ASSIGN VARIABLE <my_host FormDB.$1>
ASSIGN VARIABLE <my_dir FormDB.$2>
ASSIGN VARIABLE <my_email FormDB.$3>
ASSIGN VARIABLE <my_atti FormDB.$4>
ASSIGN VARIABLE <my_user FormDB.$5>
ASSIGN VARIABLE <my_pwd FormDB.$6>
1 POST HTTP://<APPLY my_host>/<APPLY my_dir>/index.html?emailid=<APPLY URLENC my_email>&attid=<APPLY URLENC my_atti> user=<APPLY my_user> pass=<APPLY my_pwd>
Result:
1 POST HTTP://192.168.1.1/path1/path2/path3/index.html?emailid=abc@spirent.com&attid=abc_attid user=abc&pass=xyz
ASSIGN VARIABLE <my_user "apple">
ASSIGN VARIABLE <my_pwd "bill">
1 PUT http://192.168.1.1/abc/def/index.html?user=<APPLY my_user>&password=<APPLY my_pwd>
Result:
1 PUT http://192.168.1.1/abc/def/index.html?user=apple&password=bill
ASSIGN VARIABLE <my_host "192.168.1.1">
ASSIGN VARIABLE <my_path "download">
ASSIGN VARIABLE <my_file "index.html">
ASSIGN VARIABLE <my_user "apple">
ASSIGN VARIABLE <my_pwd "bill">
1 PUT HTTP://<APPLY my_host>:80/<APPLY my_path>/<APPLY my_file>?user=<APPLY my_user>&password=<APPLY my_pwd>
Result:
1 PUT HTTP://192.168.1.1:80/download/index.html?user=apple&password=bill
ASSIGN VARIABLE <my_host_port2 "192.168.1.1:80">
ASSIGN VARIABLE <my_path "path1/path2/path3">
ASSIGN VARIABLE <my_query "?emailid=abc@spirent.com&attid=abc_attid">
1 PUT http://<APPLY my_host_port2>/path/<APPLY my_path>/dir1/dir2<APPLY my_query>
Result:
1 PUT http://192.168.1.1:80/path/path1/path2/path3/dir1/dir2?emailid=abc@spirent.com&attid=abc_attid
ASSIGN VARIABLE <my_user "apple">
ASSIGN VARIABLE <my_pwd "bill">
1 HTTPDEL http://192.168.1.1/abc/def/index.html?user=<APPLY my_user>&password=<APPLY my_pwd>
Result:
1 HTTPDEL http://192.168.1.1/abc/def/index.html?user=apple&password=bill
ASSIGN VARIABLE <my_host "192.168.1.1">
ASSIGN VARIABLE <my_path "download">
ASSIGN VARIABLE <my_file "index.html">
ASSIGN VARIABLE <my_user "apple">
ASSIGN VARIABLE <my_pwd "bill">
1 HTTPDEL http://<APPLY my_host>:80/<APPLY my_path>/<APPLY my_file>?user=<APPLY my_user>&password=<APPLY my_pwd>
Result:
1 HTTPDEL http://192.168.1.1:80/download/index.html?user=apple&password=bill
ASSIGN VARIABLE <my_host_port2 "192.168.1.1:80">
ASSIGN VARIABLE <my_path "path1/path2/path3">
ASSIGN VARIABLE <my_query "?emailid=abc@spirent.com&attid=abc_attid">
1 HTTPDEL http://<APPLY my_host_port2>/path/<APPLY my_path>/dir1/dir2<APPLY my_query>
Result:
1 HTTPDEL http://192.168.1.1:80/path/path1/path2/path3/dir1/dir2?emailid=abc@spirent.com&attid=abc_attid
If you do not specify a port number in a request, the default is 80 for HTTP, and 443 for HTTPS. If the host is a variable, and you want to use a different port number, then you must put the host and port numbers into the same APPLY statement, separated by a colon (":").
ASSIGN VARIABLE <my_host_port "192.168.58.1:8080">
1 GET HTTP://<APPLY my_host_port>/download/index.html
By definition, the absolute path in an HTTP/HTTPS request cannot be empty. If absent from the original URI, the path must be specified as "/" (the server root).
If you do not specify a slash ("/") after the host field, or if the host field is applied from a variable, then a slash ("/") will be automatically added after the host field in the URL sent to the server. (This is a client requirement per RFC 2616. If the client does not include this slash, the server will respond with an error.)
Configured:
http://192.168.58.1
Sent:
http://192.168.58.1/
Configured:
ASSIGN VARIABLE <my_host "192.168.58.1">
1 http://<apply my_host>
Sent:
http://192.168.58.1/
In some cases, two slashes may result. For example, you may specify a slash after the host field, and another may be automatically added.
Configured:
ASSIGN VARIABLE <my_host "192.168.58.1">
1 http://<apply my_host>/index.html
Sent:
http://192.168.58.1//index.html
Configured:
ASSIGN VARIABLE <my_file "/login.html">
1 https://192.168.58.1<apply my_file>
Sent:
https://192.168.58.1//login.html
NOTE: Usually, the HTTP server can handle duplicate slashes, and consider them as one slash. However, you can avoid duplicate slashes with your syntax. In the examples above, do the following:
1 http://<apply my_host>index.html
ASSIGN VARIABLE <my_file "login.html"> |
© 2024 Spirent Communications, Inc. All Rights Reserved.