The Handle dynamic HTTP 302 redirects script is used to detect a redirect (HTTP 302) in the test and set the next message’s target so subsequent requests go to that new hostname. This script looks to see if the response code was 302. If so, it resets the target of the next message to use the host name and service path specified by the Location header
Get the message that precedes this script.
Determine if the response is an HTTP 302 redirect.
Get the value of the Location header and the following protocol.
Separate the host name and service path.
Extract the host name and the service path from the location.
Set the host name and service path for the target of the next message.
The change this script makes persists across serial repeats of a clip. This script sets the target for the message immediately after this script. Since it is setting the target’s URL, all messages that use that target use this new URL.
This script overrides a target to either use or not use SSL (i.e. HTTP to HTTPS or vice versa).
In some situations when an application is deployed to a non-production environment, an IP address must be used to reach that environment (i.e. the target location is an IP address). However, the application may only respond to requests where the HTTP Request Headers include the correct hostname in the host header. This script alters the host header to include the appropriate hostname, but sends the message to the IP address. The alternative to using this script would be entering a HOSTS file entry manually on each load server.
Put the one-line script in the test clip just before the first message that utilizes the target that needs to have the host override header in it. More information can be found in the FAQ, How do I override host files for a load test?