Inserting Variables Into Request Header Fields

Applies to LoadComplete 4.97, last modified on May 20, 2019

This topic describes how you can replace header fields of requests in your scenario with variables storing data extracted from preceding responses or data that LoadComplete generates or gets from external files.

Why Insert Variables into Header Fields

Web applications can use custom fields of request headers to pass data to the server. Typically, this data is a session or user ID, which the client part receives from the server with one of the earlier requests. If you simulate a scenario for such an application with multiple virtual users, the scenario may fail because all virtual users will have the same ID.

To solve the problem, you can extract the needed data from the server response and insert it into subsequent requests, or you can replace the recorded header fields with needed data extracted from external files.

Inserting Variables Into Header Fields

  1. Open your scenario in the Scenario editor. To do this, double-click the scenario in the Project Explorer.

  2. In the Scenario Explorer, find the needed request and open it for editing.

  3. Switch to the Request page of the request editor.

  4. In the Request Header table, find the needed request header field.

  5. In the Value column, replace the field value with the variable name. Precede the variable name with the @ symbol, for example, @VariableName.

    Using Variable to Specify Request Header Field

    You can also click in the Value column and select the needed variable in the resulting dialog.

    Note: You can use a variable to specify only the entire value of the field.

    You cannot concatenate the variable name with other text. LoadComplete will not recognize the variable and will not insert the needed value into the header field.

    Supported
    Not supported

What Header Fields Cannot Be Changed

You can change all the request header fields except for the following:

  • Host - LoadComplete automatically inserts the appropriate value into this field during simulation. For information on changing request URLs, see Inserting Variables Into URLs.

  • Content-Length - POST requests use this field. It contains the size of the request body. LoadComplete automatically inserts the appropriate value into this field during simulation.

  • Cookie - To replace recorded cookies with variables values, use data replacers. In addition, you can use the cookie handling options to control how LoadComplete treats cookies during the test run.

Notes

  • Although you can parameterize other fields, we recommend that you change only custom fields added by your application. If you assign some invalid data to a header field, the server may fail to process the request.

  • If the specified variable does not exist, LoadComplete will simulate the request as is. It will not replace the header field value with an empty value.

    That is, if you specify @MyVar1, and the MyVar1 variable does not exist when LoadComplete simulates the request, the header field will contain the @MyVar1 string.

See Also

Extracting Data From Responses

Highlight search results