关于HttpQueryInfo的问题

Toxic_Obsidian 2019-02-03 02:11:41
代码(查错部分已略去)

HINTERNET hInt = InternetOpenA( UA , INTERNET_OPEN_TYPE_DIRECT , NULL , NULL , 0 );
if( hInt == NULL ){
return 1;
}
HINTERNET hConn = InternetConnect( hInt , "dl.hdslb.com" , INTERNET_DEFAULT_HTTPS_PORT , NULL , NULL , INTERNET_SERVICE_HTTP , 0 , 0 );
if( hConn == NULL ){
return 1;
}
// https://dl.hdslb.com/mobile/latest/iBiliPlayer-bili.apk
HINTERNET hTar = HttpOpenRequestA( hConn , "GET" , "/mobile/latest/iBiliPlayer-bili.apk" , "HTTP/1.1" , NULL , NULL , INTERNET_FLAG_RELOAD , 0 );
if( hTar == NULL ){
return 1;
}
if( TRUE != HttpSendRequestA( hTar , NULL , 0 , NULL , 0 ) ){
return 1;
}
CHAR dwContLength1[200];
ZeroMemory( dwContLength1 , 200 );
DWORD dwContLenBufLen;
if( TRUE != HttpQueryInfo( hTar , HTTP_QUERY_CONTENT_LENGTH , dwContLength1 , &dwContLenBufLen , NULL ) ){
return 1;
}
DWORD dwContLength = atol(dwContLength1);
cout << "Buf length=" << dwContLenBufLen << endl;
cout << "Returned " << dwContLength1 << endl;
cout << "Length got!\n" << "app size=" << dwContLength << " Bytes\n" << "app size=" << dwContLength / (1024*1024) << " MiB\n";
InternetCloseHandle( hConn );
InternetCloseHandle( hInt );
getch();

从浏览器上下载https://dl.hdslb.com/mobile/latest/iBiliPlayer-bili.apk的时候获得的apk大小是76.2MiB,然而HttpQueryInfo的时候获得的是673 Bytes,请大虾们赐教哪里出了问题
注:错误处理已省略(怕各位大虾不想看这种冗余的东西)
...全文
445 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Toxic_Obsidian 2019-02-03
  • 打赏
  • 举报
回复
我这边用HTTP_QUERY_RAW_HEADERS_CRLF输出了一下响应头,发现是HTTP/1.1 400 Bad request,所以哪位大虾能解释一下如何修改

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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