关于CHttpFile类SendRequestEx函数的一个问题

tanwei1002 2016-04-21 05:13:47
是想用SendRequestEx函数 来发送chunked数据, 代码如下


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);


上面代码SendRequestEx函数已经指定格式为HSR_CHUNKED, 但是我发送的是时候,仍然还是content_length的
具体是什么原因呢,求各位大神赐教







...全文
266 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
oyljerry 2016-04-29
  • 打赏
  • 举报
回复
可以分享一下解决的方法和原因
赵4老师 2016-04-29
  • 打赏
  • 举报
回复
encoderlee 2016-04-25
  • 打赏
  • 举报
回复
tanwei1002 2016-04-25
  • 打赏
  • 举报
回复
已解决 有人跟帖没,不然浪费分了

18,355

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧