The fields of the HTTP task can contain C# code and can be used for managing request and response data.

Prepare Script

The C# script can be used for specific POST, GET, and URL data. For example, it can be a random number generator, or it can be for pulling atypical parameters. It can be used, for example, to generate a dynamic URL depending on previous requests (for example, if it gives less than 1000 links – open URL “A” if more than 1000 links then open URL “B”).

Also, the Prepare Script code enable response or request headers modification, network throttling, and redirecting the device traffic through the specified proxy server as shown in the example below.

Example:

DotcomProxyProperties.ExternalProxyServerUri = new Uri("<custom proxi URL>:<port number>");

Post Script

By default, the device report does not include a description of the responses. The C# Post Script can be applied to the response to track any custom information in the response as cookies or a header description. In addition, an assert can be added to validate a specific response header for specified content and generate an error if the condition is not met.

Example:

var svHdr = (Tasks["twitter"] as Http).Response.Headers["Server"] ;
Assert("[Server] Header validation failure. Value is: " + svHdr, () => svHdr != null && svHdr.Contains("Cisco Umbrella"));
Response.Description = "Server: " + svHdr;

The information can be found in a device report under Description.

Please contact technical support for more details on usage.