我在用
CHttpFile *pFile=NULL;
.
.
.
CHttpFile::ReadString(strLine) 时,老是阻塞,请问是为什么呀?代码为:BOOL CHttpAPI::PostDataToServer(CString &strRetBuff, CString strObject, INTERNET_PORT nPort, CString strFormBuff)
{
BOOL bOK=true;
CString strURL,strHost,strFile,strLine,strContent="";
strURL=strObject;
if(strURL.Left(7).CompareNoCase("http://")==0)
{
strURL=strURL.Mid(7);
}
if(strURL.Find('/')==-1)
{
strURL+="/";
}
strHost=strURL.Left(strURL.Find('/'));
strFile=strURL.Mid(strHost.GetLength());

CInternetSession  mySession;
CHttpConnection* pServer=NULL;
CHttpFile* pFile=NULL;
DWORD retCode; try
{
mySession.SetOption(INTERNET_OPTION_DATA_RECEIVE_TIMEOUT,RECEIVE_TIMEOUT*1000);
mySession.SetOption(INTERNET_OPTION_DATA_SEND_TIMEOUT,SEND_TIMEOUT*1000); pServer=mySession.GetHttpConnection(strHost,nPort); pFile=pServer->OpenRequest("POST",(LPCTSTR)strFile);
pFile -> AddRequestHeaders("Content-Type: application/x-www-form-urlencoded");
pFile -> AddRequestHeaders("Accept: */*");
pFile->SendRequest(NULL,0,(LPVOID)(LPCTSTR)strFormBuff,strFormBuff.GetLength());

}
catch(CInternetException e)
{
::AfxMessageBox("发生了一点错误");
e.Delete();
bOK=false;
} pFile->QueryInfoStatusCode(retCode);

if(bOK)
{
try
{
while(pFile->ReadString(strLine)) //在这里阻塞!!!郁闷呀!
{
strContent+=strLine+"\r\n";
}
strRetBuff=strContent;
}
catch(CInternetException e)
{
::AfxMessageBox("Error!! ReadString()");
e.Delete(); }
} pFile->Close();
pServer->Close();
delete pFile;
delete pServer;
mySession.Close(); return bOK;
}