WebPageStatGetRootNode Function

Action

Returns the root node of the most recently loaded page. A node is a request/response pair which is illustrated as one element of the page-tree in TrueLog Explorer. Dependent of the setting specified by the call to WebSetOption, the returned node is either the first issued request (PAGE_STAT_FLAG_RedirChainOnlyFirst) or, if this request is redirected or retried, the last one when called with a value of PAGE_STAT_FLAG_RedirChainOnlyLast. The optional flag parameter can be used to overwrite the default flag value specified by the call to WebSetOption.

The return value is a node ID, which can be used in various other WebPageStatXXX calls.

To generally enable the extended page statistics functionality, call WebSetOption with an option of WEB_OPT_DETAILED_PAGE_STAT. For a detailed description of the various values see WebSetOption().

Include file

WebAPI.bdh

Syntax

WebPageStatGetRootNode( in nFlags: number optional ): number;

Return value

  • 0 if the node could not be found

  • >0 otherwise

Parameter Description
nFlags

Specifies the various options used by the search for the root node. If this parameter is omitted, the default options specified by the call to WebSetOption(WEB_OPT_DETAILED_PAGE_STAT) are used. Otherwise, specify one of the following values:

PAGE_STAT_FLAG_UseHtml
Returns nodes of the document section of the page (commonly html documents).
PAGE_STAT_FLAG_NodeTypeLoad
Returns nodes that caused a request to be sent to the server (no cache hits and no suppressed documents).
PAGE_STAT_FLAG_NodeTypeCacheHit
Returns nodes that have been found in the cache (full cache hit), so that no request to the server has been sent.
PAGE_STAT_FLAG_NodeTypeSuppress
Returns nodes for which no request has been sent to the server, because they have been suppressed by the user (WebPageSuppress or WebSetDomainSuppress).
PAGE_STAT_FLAG_RedirChainOnlyLast
Returns the last node of a potential redirection chain. (A redirection chain evolves when a request is retried or reissued because of a redirection or an authentication request by the server).

Example

dcltrans
  transaction TInit
  begin
    WebSetOption(WEB_OPT_DETAILED_PAGE_STAT,
                 PAGE_STAT_FLAG_AllLoadedDocs);
  end TInit;

  transaction TWeb
  var
    nNode  : number;
    fValue : float;
    sUrl   : string;
  begin
    WebPageUrl("http://lab3/");
    nNode := WebPageStatGetRootNode();
    if nNode > 0 then
      WebPageStatGetNodeInfo(null, sUrl);
      print("Root Url: " + sUrl);

      if WebPageStatGetFirstFrame(nNode) > 0 then
        WebPageStatGetNodeData(STATFLAG_BytesSent, fValue);
        print("BytesSent: " + string(fValue));
      end;
    end;
  end TWeb;