本文整理自网络,侵删。
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》频道 >>