URL Redirects
A request for a page or resource can often be met with a response instructing the browser that it should fetch the target from a new location. These redirect responses are indicated by the following HTTP return codes:
301 (Moved Permanently). The resource has moved and all future requests for that resource should be made to a new URL.
302 (Found). The resource has moved, but future requests should continue to come to the original URL.
303 (See Other). The response to your browser's request can be found elsewhere.
307 (Temporary Redirect). Requested data temporarily resides at a new location.
How Eggplant Performance Handles Redirects
Redirects will be automatically followed at runtime if the web script contains setFollowRedirects(true). This statement is originally set by a generation option but can be manually overridden with script code.
If FollowRedirects is true then a navigation for a redirect will look similar to the following:
// ====================================================================================================================================
// Request: 5, GET, http://bosch:8080/admin, response code=302 Found: redirect occurred
// ====================================================================================================================================
// Page Title: Server Administration
_url.setHost(_host1);
_url.setPath("/admin");
_url.setPort(8080);
navigateGet(_url);
// Request: 6, GET, http://bosch:8080/admin/, response code=200 OK
The above script fragment shows via comments that a redirect occurred and that the script must have been generated with the option to automatically follow redirects set to true. The initial comment displays the original request and its response code (302). After the navigateGet() statement a further comment shows the URL to which the original request was redirected during recording. During replay, if the request is redirected to another location it will follow the redirection as instructed. Compare this to the following example generated with follow redirects set to false.
// ===================================================================================
//Request: 5, GET, http://bosch:8080/admin, response code=302 Found: redirect occurred
// ===================================================================================
_url.setHost(_host1);
_url.setPath("/admin");
_url.setPort(8080);
navigateGet(_url);
// ===================================================================================
// Request: 6, GET, http://bosch:8080/admin/, response code=200 OK
// ===================================================================================
// Page Title: Server Administration
_url.setPath("/admin/");
navigateGet(_url);
In this example, the redirect is effectively hard-coded within the script. Request 6 will always be requested.