Skip to main content

Verify HTTP Response Status Code Rule

The Verify HTTP Response Status Code rule is one of the rules you can apply when you generate a web virtual user (VU) script from a recording in Eggplant Performance Studio using the Generation Rules wizard. To ensure that the server's responses to the VU's requests are correct, you can specify that the script perform a simple check to verify that the response code of an HTML response is what you expect.

Verify HTTP Response Status Code rule

This Verify HTTP Response Status Code rule is useful if you are trying to check for 404 or redirect codes, or if you expect the server to respond with different status codes in different circumstances.

Example Script Code Changes (Java)

The following code shows the effect of applying the Verify HTTP Response Status Code rule:

try (Response response1 = request1.send())
{
....
}

changes to:

try (Response response1 = request1.send())
{
response1.verifyResult(HttpStatus.OK, ActionType.ACT_WARNING);
....
}

Generation Rules Wizard Pages

The pages you see in the Generation Rules Wizard vary depending on the type of rule you select and whether you are creating a new rule or editing an existing one. Following are the pages you see when you create or edit a Verify HTTP Response Status Code rule:

Set the Expected HTTP Response Code Page

The Set the expected HTTP response code page provides options for the way you can look for a response status code.

The value obtained must be an integer (such as 200). This affects the Data value option, because the script will expect to retrieve an integer from the data dictionary using getInt(string key).

  1. Choose from where you want to get the expected response code. The Set the expected HTTP response code page changes depending on the option you select:

    • Value from dictionary: If you select the Value from dictionary option, the Set the expected HTTP response code changes to provide a Key field for you to enter value from your data dictionary.

      The HTTP response code is an integer retrieved from a data source using the provided key, which enables each VU to verify a different value during the test. For information about VU data dictionaries, see The Virtual User Data Dictionary. You must enter a value here to proceed through the wizard.

      note

      If you choose this option, you must define a data binding for the test, and the data file must contain values with a matching key. For information about defining data bindings at the test level, see Assigning Data Sources to Eggplant Performance Tests.

    • Fixed value: If you select this option, the Set the expected HTTP response code changes to provide a drop-down list of common HTTP response status codes for you to select. You must select a response code to proceed through the wizard.

    • Response codes of the requests in the recording: The HTTP response code to verify is the response code of each received response in the recording. This verifies that the server is returning the same responses (for example, 200, 404, or 500) as the responses received during recording. You do not enter anything for this option. You can proceed through the wizard.

    • Function call (advanced): If you select Function Call, the Set the expected HTTP response code page changes to provide a Function field for you to enter a function call. You must enter a value here to proceed through the wizard.

  2. When you finish using the Set the expected HTTP response code page, click Next. The common Success/failure options page opens for you to specify what action to take if the title matches or doesn't match.

  3. Proceed through the wizard. After the Select Success/Failure options page, the common pages Create Request Filter and Rule name and summary follow.