- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
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;