Delphi TIDHttp.Authentication用法
Indy9.0是一套基于delphi的Internet开发组件,功能非常丰富。大多数时候,我们都会用TIDHttp组件向server端来模拟发送post或get请求,有些网站从安全角度考虑,都会要求client验证通过后,才能访问。
那么如何在TidHTTP中发送验证需要的用户名与密码呢?示例代码如下:
MyHttp := TIdHttp.Create(nil);   
try    
  MyHttp .Request.Clear;    
  MyHttp .Request.BasicAuthentication := True; 
  MyHttp .Request.Authentication.Username := admin;   
  MyHttp .Request.Authentication.Password := admin;    
end;    
  MyHttp .Get('http://192.168.1.129');    
finally    
  MyHttp .Free;    
end;
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号