在 OnProxyAuthorization 中提供 Indy 代理帐户
使用 TIdHTTP 的代理身份验证事件,在验证机制向应用程序索取帐户时提供帐户。
TIdHTTP 公开 OnProxyAuthorization,用于代理身份验证机制要求应用程序提供帐户的时刻。回调接收 TIdAuthentication 对象和 Handled 结果:
procedure TForm1.IdHTTP1ProxyAuthorization(Sender: TObject;
Authentication: TIdAuthentication; var Handled: Boolean);
begin
Authentication.Username := 'PROXY_USER';
Authentication.Password := 'PROXY_PASSWORD';
Handled := True;
end;
为该类型使用 IdAuthentication 单元,并将此方法分配给 HTTP 组件的 OnProxyAuthorization 事件。将占位值替换为应用程序凭据逻辑提供的帐户。
返回 Handled=true 可让身份验证机制继续使用这些值。当用户取消或应用程序拒绝提供凭据时,返回 false。
代理终结点仍然属于组件的 ProxyParams 配置。回调参与所选方案的交换;它不需要自行计算 Basic 或 NTLM 标头。