代码改变世界

idhttp访问出现onnection closed gracefully

2020-07-07 11:47  su_hq  阅读(389)  评论(0编辑  收藏  举报

idhttp=new TIdHTTP(NULL);
idhttp->AllowCookies =true;
idhttp->HandleRedirects =true; //允许重定向
idhttp->ConnectTimeout =20000;
idhttp->ReadTimeout =20000;
//hoInProcessAuth, hoKeepOrigProtocol, hoForceEncodeParams, hoNonSSLProxyUseConnectVerb, hoNoParseMetaHTTPEquiv, hoWaitForUnexpectedData, hoTreat302Like303, hoNoProtocolErrorException, hoNoReadMultipartMIME, hoNoParseXmlCharset, hoWantProtocolErrorContent, hoNoReadChunked
idhttp->HTTPOptions <<hoKeepOrigProtocol;  //这一句很关键
//pv1_0, pv1_1
idhttp->ProtocolVersion =pv1_1;

SSLIO=new TIdSSLIOHandlerSocketOpenSSL();
//sslvSSLv2, sslvSSLv23, sslvSSLv3, sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2
SSLIO->SSLOptions->Method = sslvTLSv1_2;
//sslmUnassigned, sslmClient, sslmServer, sslmBoth
SSLIO->SSLOptions->Mode = sslmClient;
SSLIO->ConnectTimeout =20000;
idhttp->IOHandler=SSLIO;