web_add_header

Adds the specified header to the next HTTP requests.

C Language

int web_add_header( const char *Header, const char *Content );

Java Language

int object.add_header( String Header, String Content );
Argument
Description
object
An expression evaluating to an object of type WebApi. Usually web for Java. See also Function and Constant Prefixes.
Header
The name of the user–defined header.
Examples: "Accept", "Accept–Encoding"
Content
The value (data) associated with the user–defined header.

Return Values

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.

Parameterization

The following argument(s) can be parameterized using standard parameterization: Header, Content

General Information

The web_add_header function is a service function that adds a user–defined header to the next HTTP request.

Web scripts automatically send standard headers with each HTTP request they submit. You can define additional user–defined headers from the Advanced tab in the Recording Options dialog box in VuGen. When you enable headers from the Recording Options, VuGen generates a web_add_header function with the specified headers. It is recorded only when the recording headers option is enabled (see VuGen's Recording Advanced Options).

When two consecutive steps require headers, the web_add_auto_header function is generated automatically. You can also manually add the web_add_auto_header function to your script. The advantage of using web_add_auto_header is that it applies to all HTTP requests that follow, unlike web_add_header, which only applies to the HTTP request that follows it.

One common use of user–defined headers is to add user agent information. User agent information is often used for statistical purposes, for tracing of protocol violations, and for automated recognition of user agents for the sake of tailoring responses to avoid particular user agent limitations, such as inability to support HTML tables.

This function is supported for all web scripts. This function may be used in concurrent groups.

Note: This function ignores web_rest (or web.rest) steps which send REST API requests.