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
In the Scenario Explorer, find the needed request and open it for editing.
Switch to the Request page of the request editor.
In the Request Header table, find the needed request header field.
In the Value column, replace the field value with the variable name. Precede the variable name with the
@symbol, for example,
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.
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.