18,355
社区成员
发帖
与我相关
我的任务
分享
int nLen = strBody.GetLength(); //strBody为待发送的数据
char szHex[10]={0};
itoa(nLen,szHex,16);
CString strMTBody;
strMTBody.Format("%s\r\n%s\r\n0\r\n\r\n", szHex, strBody); //得到chunked格式的发送内容
INTERNET_BUFFERS BufferIn;
memset(&BufferIn, 0, sizeof(BufferIn));
BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS ); // Must be set or error will occur
BufferIn.Next = NULL;
BufferIn.lpcszHeader = NULL;
BufferIn.dwHeadersLength = 0;
BufferIn.dwHeadersTotal = 0;
BufferIn.lpvBuffer = NULL;
BufferIn.dwBufferLength = 0;
BufferIn.dwBufferTotal = strMTBody.GetLength(); // This is the only member used other than dwStructSize
BufferIn.dwOffsetLow = 0;
BufferIn.dwOffsetHigh = 0;
BOOL bSend = pFile->SendRequestEx(&BufferIn, NULL, HSR_CHUNKED, 1); //HSR_CHUNKED
pFile->Write((LPVOID)(LPCTSTR)strBody, strMTBody.GetLength());
bSend = pFile->EndRequest(0, NULL, 1);