18,356
社区成员
发帖
与我相关
我的任务
分享
BOOL CWinHttpRequest::RecvResponseData()
{
cout << "开始接收数据" << endl;
m_pHttpResponse->Clear();
BOOL bAllDone = FALSE;
char lpReadBuff[1024];
do
{
INTERNET_BUFFERS InetBuff;
FillMemory(&InetBuff, sizeof(InetBuff), 0);
InetBuff.dwStructSize = sizeof(InetBuff);
InetBuff.lpvBuffer = lpReadBuff;
InetBuff.dwBufferLength = sizeof(lpReadBuff);
if(!InternetReadFileEx(m_hRequest, &InetBuff, IRF_ASYNC, (DWORD_PTR)m_pContext))
{
if(GetLastError() == ERROR_IO_PENDING)
WaitRequestComplete();
else
{
cout << "InternetReadFileEx failed, error " << GetLastError();
cout.flush();
return FALSE;
}
}
m_pHttpResponse->AppendData(lpReadBuff, InetBuff.dwBufferLength);
if(InetBuff.dwBufferLength == 0)
bAllDone = TRUE;
}
while(bAllDone == FALSE);
cout << "数据接收完毕" << endl;
return TRUE;
}
httpHeader.Add(_T("Content-Type: application/x-www-form-urlencoded\r\n"));
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<? echo file_get_contents("php://input"); ?>
</head>
</html>