WebSetProxyAuth Function

Action

Sets the password for proxy authentication login. Use empty strings or NULL values to disable proxy authentication.

注: This function overrides the corresponding setting in the Simulation tab of the Profile Settings - Web dialog.

Include file

WebAPI.bdh

Syntax

WebSetProxyAuth( in sUsername     : string allownull,
                 in sPassword     : string optional,
                 in sProxy        : string optional,
                 in bReactiveOnly : boolean optional): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
sUsername User name for proxy authentication. This parameter may be NULL.
sPassword Password for proxy authentication. This parameter may be NULL (optional).
sProxy Proxy for which the username and password should be set (optional). If this parameter is omitted the username and password will be used for authentication after the next 407 response from the server.
bReactiveOnly If this parameter is set to true (default is false; optional), the user and password pair can only be used in a reaction to a 407 response from the server.

Calling this function inserts the username/password pair into the authentication database used when a server requests proxy authentication (code 407). On subsequent requests, the authentication header line will be added to the request headers automatically.

  • To set the default username password, call WebSetUserAuth("user1", "pass1");

  • To delete the default username/password, call WebSetUserAuth("", ""); This does not remove the entry from the authentication database.

  • To remove all cached authentication entries from the cookie database, call WebSetUserAuth(NULL, NULL);

  • In addition, you can add authentication entries directly to the authentication database by providing a protection space and the realm. For example, WebSetUserAuth("BasicAuthUser", "BasicAuthPass", "proxy", false);

Example

dcltrans
  transaction TWebInit
  begin
    // Set up proxy connection using the WebSetting commands
    WebSetProxy(WEB_PROXY_HTTP, "proxy.mydomain.com", 80);
    WebSetProxyBypass(FALSE, NULL);     // Set password used for authentication
    WebSetProxyAuth("proxyuser", "proxypass", "proxy:80");
    WebSetProxyAuth("proxyusersecure", "proxypasssecure", "proxy:443");
  end TWebInit;

Sample scripts

WebAuth01.bdf