WebSetAutoRedirect Function

Action

Specifies whether Silk Performer automatically parses redirection responses and redirects the request to the specified server.

Include file

WebAPI.bdh

Syntax

WebSetAutoRedirect( in bAuto     : boolean,
                    in nMaxRedir : number optional,
                    in nFlag     : number optional ) : boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
bAuto If this parameter is set to true, Silk Performer automatically parses redirection responses and redirects the request to the specified server
nMaxRedir Specifies the maximum number of redirections that are automatically performed by Silk Performer (optional). The default value for this parameter is 5.
nFlag

Specifies whether to modify the standardhost variable (optional). This parameter can be one of the following:

WEB_AUTOREDIR_SETSTDHOST_FIRST
Sets the standardhost variable to the new location on the next redirection.
WEB_AUTOREDIR_SETSTDHOST_ALWAYS
Sets the standardhost variable to new location on all redirections.

The function’s default behavior is not to modify the standardhost variable.

The following error message is reported if too many redirections requests are received in a row:

HTTP: 1010 - too many redirections, possibly loop detected.

A possible reason for this error is that the script has not been customized properly. For example, a script must correctly handle session IDs that cause a Web application to send redirection messages.

Example

dcltrans
  transaction TMain
  var
    sUrl, sParam1, sSession: string(1000);
  begin
    // automatic redirect
    WebSetAutoRedirect(true);
    WebUrl("http://standardhost/SessionIdTest.asp");
    // manual redirect
    WebSetAutoRedirect(false);
    WebParseResponseRedirect(sUrl, sizeof(sUrl), NULL);
    WebParseResponseRedirect(sParam1, sizeof(sParam1), "Param1");
    WebParseResponseRedirect(sSession, sizeof(sSession),
                             "SessionID");
    WebUrl("http://standardhost/SessionIdTest.asp");
    writeln(sUrl); writeln(sParam1);
    writeln(sSession);
  end TMain;

Sample scripts

WebAuth01.bdf, WebHttpHeaders01.bdf, WebParseResponseHeader01.bdf, WebSecure02.bdf