JavaScript Functions > Alphabetical Listing of Web Functions > web.saveHeader

web.saveHeader

Saves request and response headers to a parameter.

Syntax

web.saveHeader( type, param ); 
Property Name
Description
type
The type of header: REQUEST or RESPONSE
param 
The parameter name.

Return Values

Not applicable

Parameterization

Standard parameterization is not available for this function.

General Information

The web.saveHeader function saves request and response headers of the primary URL of all ensuing action Functions to the parameter param. Each header is delimited by "\r\n" (or just "\n"). Each new request header replaces the existing value of the parameter.

If type is REQUEST, web.saveHeader saves all subsequent request headers to param.

If type is RESPONSE, web.saveHeader saves all subsequent response headers to param.

To instruct a script to stop saving headers, insert a web.saveHeader function and specify an empty string ("") for the parameter, for example, web.saveHeader(RESPONSE,"");. After this call, subsequent headers are not saved. The last value of param remains unchanged unless some other function changes it.

It is inefficient to use web.saveHeader to extract information, like cookies, from headers. Instead, use web.regSaveParamEx specifying "search=Headers"

When a script accesses a URL, the web.saveHeader function saves only the original user request and server response. While displaying a page, additional requests and responses are generated when the HTML code requires data about images and frames that are contained inside the Web page. The web.saveHeader function does not save these subsequent requests and responses.

If the server redirects the request to access another URL, then the web.saveHeader function saves only the header of the last (redirected) request.

Saving headers is not supported for scripts including concurrent groups.

Example

web.saveHeader("RESPONSE","response header");
web.saveHeader("REQUEST","request header");

web.customRequest(...);

lr.outputMessage("request header: "+lr.evalString("{request header}"));
lr.outputMessage("response header: "+lr.evalString("{response header}"));