Share this page

# web_add_auto_header

Adds the specified header to all subsequent HTTP requests.

## C Language

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

Example: web_add_auto_header | Header Functions

## Java Language

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

Example: web.add_auto_header | 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 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. Note that in many cases, this return value indicates the technical success of the function, and not the result. For example, a function that registers a string to be found in a subsequent step returns LR_PASS to indicate that the registration was successful. This does not indicate that the string was found in the server response.

## Parameterization

The following argument(s) can be parameterized using standard parameterization: header, content.

## General Information

The web_add_auto_header function is a service function that adds a header to all subsequent HTTP requests.

Web scripts automatically send standard headers with each HTTP request they submit. You can add additional headers using the web_add_auto_header function. This instructs VuGen to generate the specified header for all HTTP requests that follow. This is in contrast to the web_add_header function that applies only to the HTTP request that follows it.

The web_add_auto_header function is generated automatically when headers are required for two consecutive steps, provided that header generation is enabled in the Advanced tab of the Recording Options. Refer to Setting Advanced Recording Options in the Virtual User Generator Help Center.

You can also add this function to your script manually.

To enable compression and decompression for browsers, set the Accept–Encoding option to gzip:

`web_add_auto_header("Accept–Encoding", "gzip");`

You can verify if the server sent compressed data, by searching for the string `"Content–Encoding: gzip"` in the Execution log.``

To cancel automatic header generation, use:

- web_cleanup_auto_headers to stop all automatic header generation.

- web_remove_auto_header to stop automatic header generation for a specific header.

- web_revert_auto_header to stop automatic header generation for a specific header, but allow the generation of Implicit Headers.

Note:

- This function is supported for all web scripts running in HTTP or Wireless Session Protocol (WSP) replay mode.
- This function may not be used in concurrent groups.
- This function ignores web_rest (or web.rest) steps which send REST API requests.

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