WebParseResponseHeader Function


Parses the HTTP headers of a server response and stores the header value in sResult. When the search parameter is not specified (set to NULL), all HTTP headers are retrieved at once. The nResponseNo parameter specifies which response header is subject of interest. If this parameter is omitted, all response headers are checked (If a header is not found in the first response, Silk Performer looks for it in the next response). If the nResponseNo, the sHeaderName, and the nResponseNo parameters are omitted, the first call retrieves the first complete response header. All subsequent calls (with the last 3 parameters omitted) retrieve the subsequent response-headers. The subsequent low-level web function will not return until the request has finished. Other requests started before may run in parallel.

It is important to know that all parsing and verification functions must be specified before the Web API call for which the response data should be parsed/verified. You can specify multiple parse/verification functions before a Web API call. The order of the parse/verification functions is not relevant (Exception: WebParseDataBound and WebVerifyDataBound using the flag WEB_FLAG_SYNCHRON).

Note: If you want to parse a Web server response, you must first call the WebParseResponseHeader function. Then you send the request to the Web server.

Include file



WebParseResponseHeader( out sResult       : string,
                        in  nMaxResultLen : number optional,
                        in  sHeaderName   : string optional,
                        in  nHeaderNo     : number optional,
                        in  nResponseNo   : number optional): boolean;

Return value

  • true if the parsing modifier could be created successfully

  • false otherwise

Parameter Description
sResult String variable that receives the value of the HTTP header or all HTTP headers (CRLF separated)
nMaxResultLen Maximum length of the string to return (optional). If this parameter is omitted or set to STRING_COMPLETE all available data is stored in sResult.
sHeaderName Name of the header for which to retrieve the associated value (optional). Passing a NULL value will store all HTTP headers CRLF separated into sResult.
nHeaderNo Index of the header value to be retrieved (optional). If this parameter is omitted, all values are concatenated (with commas as separators between the values).
nResponseNo Index of the response header value that is to be retrieved or searched (optional). If this parameter is omitted, all response headers are searched; if the sHeaderName parameter is omitted as well, the order of the function calls specifies which response header to get. If this parameter is set to WEB_RESPONSE_LAST, the last response header is searched.


  transaction TWeb
    sHeader1 : string;
    sHeader2 : string;
    sServer1 : string;
    sServer2 : string;
    WebParseResponseHeader(sHeader2, STRING_COMPLETE);
    WebParseResponseHeader(sServer1, STRING_COMPLETE, "server", 1, 2);
    WebUrl("http://standardhost/", 0.0);

    write(sHeader1); writeln;
    write(sHeader2); writeln;
    write(sServer1); writeln;
    write(sServer2); writeln;
  end TWeb;

Sample scripts

WebParseResponse01.bdf, WebParseResponseHeader01.bdf