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 数组类型与数组指针的巧妙利用

Delphi 获取网页源代码的最简单办法

Delphi posansi

Delphi二值图像膨胀算法

Delphi 取得ie下面输入框内容

Delphi xp下的进程静音技术

Delphi的stringreplace 字符串替换函数

Delphi 2009 之 tstringbuilder 类[4]: insert 与 remove

Delphi 获取外网ip的函数

Delphi 窗体的位置和高宽度-tform:letf、top、width、height、clientwidth、clientheight

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



打赏

取消

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

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

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

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

评论

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