Share this page

# web_add_header

Adds the specified header to the next HTTP requests.

## C Language

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

Header Functions

## Java Language

    int object.add_header( String Header, String Content );

Header Functions | Java Syntax

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.

## C Example

In the following examples, web_add_header is used to add headers to subsequent HTTP requests:

    web_add_header("User-Agent", "ABC Browser 1.0"); // informs the server that the name of the custom browser application that the client is using to send the request is ABC Browser 1.0
    web_add_header("Accept", "text/xml/html"); // *.* is the default sent if no Accept header is specified.
    web_add_header("userid", "sam");  // Add a custom header for application specific login logic.
    web_add_header("pwd", "****");    // Add a custom header for application specific login logic.

## Java Example

In the following example, the add_header function informs the server that the name of the custom browser application that the client is using to send the request is ABC Browser 1.0:

    web.add_header ("User-Agent", "ABC Browser 1.0" );

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: