c++ - Qt- QNetworkReply 不显示 Content-Length header

标签 c++ qt http networking

对于某些下载 url,QNetworkReply 对象不包含 Content-Length header 并返回文件大小为 -1。我测试了以下网址:

http://download-cf.jetbrains.com/webide/PhpStorm-EAP-141.332.tar.gz

Firefox 中 Live HTTP Headers 显示的 header 如下:

HTTP/1.1 200 OK
Content-Type: application/x-tar
Content-Length: 135144452
Connection: keep-alive
Date: Mon, 30 Mar 2015 17:49:03 GMT
Content-Encoding: gzip
x-amz-meta-s3cmd-attrs: uid:572/gname:cds/uname:cds/gid:574/mode:33188/mtime:1427282503/atime:1427282968/md5:a2ccadce9ae0f356e9c11a6d5dd5a4f0/ctime:1427282503
Last-Modified: Wed, 25 Mar 2015 11:36:03 GMT
Etag: "db9a27ca51b84bac23080028b3e267ef-9"
Accept-Ranges: bytes
Server: AmazonS3
Age: 313
X-Cache: Miss from cloudfront
Via: 1.1 f94856caaa8ad33df4ddf975899fadd2.cloudfront.net (CloudFront)
X-Amz-Cf-Id: GFsaZTTMQ5eQ54JOUzBfJmIHL6AolKkXknb2HAcfbCKsbIYgdJng_Q==

当我执行以下操作时:

qDebug()<<reply->rawHeaderList();

输出是:

("Content-Type", "Connection", "Date", "Content-Encoding",
"x-amz-meta-s3cmd-attrs", "Last-Modified",
"ETag", "Accept-Ranges", "Server", "Age", "X-Cache",
"Via", "X-Amz-Cf-Id")

显然,缺少 Content-Length。那么,他们对此是否有任何解决方案。

最佳答案

我已经记录了一个相同的错误报告。可以在以下网址进行跟踪:

https://bugreports.qt.io/browse/QTBUG-45322

关于c++ - Qt- QNetworkReply 不显示 Content-Length header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29353254/

相关文章:

c++ - 了解使用 boost::asio 和 boost::thread 时的内存泄漏

c++ - 使用 NULL 引用可以吗?

c++ - 具有默认成员初始化器的 std::array 的零初始化元素

linux - 构建时 Qt : qml quick, 中的未知模块

c++ - 对 staticMetaObject 的 undefined reference

javascript - Angular JS TypeScript IHttpService 注入(inject)自定义 header 值

rest - 如何在jmeter中使http请求中的搜索参数为动态的

c++ - 在自定义容器类中使用分配器

c++ - QT - 检查 QT 应用程序是否是焦点应用程序

c# - 如何将文件拆分成多个部分并下载