winInet 访问https总是出错,求解
向https://vpn3.foton.com.cn/prx/000/http/localhost/login发包总是错误,代码如下
uri := TIdURI.Create(url);
host := uri.Host;
ShowMessage('host为'+host);
path := uri.Path + uri.Document;
proto := uri.Protocol;
uri.Free;
if UpperCase(proto) = 'HTTPS' then
begin
port := INTERNET_DEFAULT_HTTPS_PORT;
dwFlags := INTERNET_FLAG_SECURE or SECURITY_INTERNET_MASK or INTERNET_FLAG_RELOAD;
end
else
begin
port := INTERNET_INVALID_PORT_NUMBER;
dwFlags := INTERNET_FLAG_RELOAD;
end;
hInt := InternetOpen('Project1',INTERNET_OPEN_TYPE_PRECONFIG,nil,nil,0);
hConn := InternetConnect(hInt,PChar(host),port,nil,nil,INTERNET_SERVICE_HTTP,0,0);
hreq := HttpOpenRequest(hConn,'GET',PChar(Path),'HTTP/1.1',nil,Pointer(AcceptTypes),dwFlags,0);
GetMem(buffer, 65536);
if HttpSendRequest(hReq,nil,0,PChar(data),Length(data)) then
begin
dwRead:=0;
repeat
InternetReadFile(hreq,buffer,65536,dwRead);
if dwRead<>0 then
res.Write(buffer^, dwRead);
until dwRead=0;
end
error:=GetLastError;
ShowMessage(IntToStr(error));
总是不成功,提示120错误