Delphi Android使用idhttp.get抓取https(SSL)文件


本文整理自网络,侵删。

 
uses
 IdSSLOpenSSL,idhttp;
function HttpsAuthGet(Url, Username, Password: string):string;
var
  ssl: TIdSSLIOHandlerSocketOpenSSL;
  http: TIdHTTP;
begin
  http := TIdHttp.Create(nil);
  try
    ssl := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
    try
      http.IOHandler := ssl;
      http.Request.BasicAuthentication:=True;
      http.Request.Username := Username;
      http.Request.Password := Password;
      Result:=http.Get(Url);
      if (http.ResponseCode<200) or (http.ResponseCode>=300) then
        raise Exception.Create(http.ResponseText);
    finally
      FreeAndNil(ssl);
    end;
  finally
    FreeAndNil(http);
  end;
end;

相关阅读 >>

Delphi tstringdynarray 使用,分割字符串

Delphi一个综合实用的单元

Delphi tnethttpclient上传文件

Delphi10.3.2安卓sdk安装

Delphi登陆验证方法

cnpack sqlite tool 2.04

Delphi 获取路径分隔符

Delphi 批量把图片保存到access数据库

Delphi 如何判断字符串是否是有效email地址

Delphi xe [dcc32 fatal error] f2039 could not create output file 问题的解决

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...