web_save_header

Saves request and response headers to a parameter.

C Language

int web_save_header( constchar *type, const char *param ); 

Java Language

int object.save_header( String type, String param ); 
Argument
Description
object
An expression evaluating to an object of type WebApi. Usually web for Java. See also Function and Constant Prefixes.
type
The type of header: REQUEST or RESPONSE
param 
The parameter name.

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: Name

General Information

The web_save_header 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_save_header saves all subsequent request headers to param.

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

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

Note:
1. It is inefficient to use web_save_header to extract information, like cookies, from headers. Instead, use web_reg_save_param specifying "Search=Headers"

2. When a script accesses a URL, the web_save_header 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_save_header function does not save these subsequent requests and responses.

3. If the server redirects the request to access another URL and the redirection is explicitly recorded, then the web_save_header function saves only the header of the last (redirected) request. If redirection is not explicitly recorded, only the first header is saved.

4. Saving headers is not supported for scripts including concurrent groups.

This function is supported for all web scripts.

C Example

In the following example, the request and response headers are saved to two parameters, "response header" and "request header". At each web_url call, the contents of the parameters are replaced.

web_save_header(RESPONSE,"response header"); 
web_save_header(REQUEST,"request header"); 
web_url("John_Willoughby", 
    "URL=http://Combe_Magna.com/portal/index.asp", 
    "TargetFrame=_TOP", 
    LAST );     
web_url("George_Wickham", 
    "URL=http://Meryton.com/regiment/", 
    "TargetFrame=_TOP", 
    LAST );     
After web_url "John_Willoughby" :

Action.c(9): Notify: Saving Parameter "request header = GET /portal/index.asp HTTP/1.1\r\nAccept: */*\r\nUser–Agent: Mozilla/4.0 (compatible; MSIE 4.0; Windows NT)\r\nConnection: Keep–Alive\r\nHost: Combe_Magna.com\r\n\r\n"

Action.c(9): Notify: Saving Parameter "response header = HTTP/1.1 200 OK\r\nServer: Microsoft–IIS/4.0\r\nDate: Sun, 10 Aug 2003 13:38:28 GMT\r\nContent–Type: text/html\r\nSet–Cookie: ASPSESSIONIDQQGGGHHK=IGDLGLJALBHDNEDBBNIOHNOG; path=/\r\nCache–control: private\r\nTransfer–Encoding: chunked\r\n\r\n"
After web_url "George_Wickham":

Action.c(17): Notify: Saving Parameter "request header = GET /regiment/ HTTP/1.1\r\nReferer: http://Combe_Magna.com/portal/index.asp\r\nAccept: */*\r\nUser–Agent: Mozilla/4.0 (compatible; MSIE 4.0; Windows NT)\r\nConnection: Keep–Alive\r\nHost: Meryton.com\r\n\r\n"

Action.c(17): Notify: Saving Parameter "response header = HTTP/1.1 200 OK\r\nServer: Microsoft–IIS/5.0\r\nDate: Sun, 10 Aug 2003 13:43:18 GMT\r\nCache–Control: private\r\nContent–Type: text/html; charset=utf–8\r\nContent–Length: 11346\r\n\r\n"

Java Example

In the following segment, the web.save_headerfunction first saves the HTML response header that the browser receives when it accesses the cookie.html page. The header is saved to the parameter "response header." When the script accesses "dogbert," the save_header function then saves the HTML response header that the browser receives from dogbert. This header replaces the previous value saved to "response header."

try
{
web.save_header(web.RESPONSE,
    "response header");
web.url("cookie.html",
     "URL=http://www.RosingsPark.com/cookie.html",
     new String []{
         "TargetFrame=_TOP",
         web.LAST
     });
web.url("dogbert",
     "URL=http://dogbert/",
     new String []{
         "TargetFrame=_TOP",
         web.LAST
     });
}
catch (Exception e) {}