【发布时间】:2013-02-19 20:45:01
【问题描述】:
我正在尝试使用 libcurl 7.20.0 和 openssl 0.9.8l 下载文件(但我将库更新为 7.29.0 和 1.0.1e),Windows 7 并且一切都在为 amd64 编译以下载大文件.我使用 curlpp 作为 curl 的包装器。问题是,一旦达到 2GB,下载就会停止并出现错误Failed writing body (0 != 8999)。我用来做请求的代码是:
boost::shared_ptr<curlpp::Easy> curl_request(boost::make_shared<curlpp::Easy>());
curl_request.setOpt(new curlpp::options::HttpVersion(CURL_HTTP_VERSION_1_0));
curl_request.setOpt(new curlpp::options::Timeout(3600));
curl_request.setOpt(new curlpp::options::SslVerifyHost(0));
curl_request.setOpt(new curlpp::options::SslVerifyPeer(0));
curl_request->setOpt(new curlpp::options::Url(request_uri));
if (cookies.size() == 0) {
curl_request->setOpt(new curlpp::options::CookieList("dummy"));
} else {
BOOST_FOREACH(const std::string &cookie, m_cookies) {
curl_request->setOpt(new curlpp::options::CookieList(cookie));
}
}
curl_request->setOpt(new curlpp::options::Post(true));
curl_request->setOpt(new curlpp::options::PostFields(query_string));
curl_request->setOpt(new curlpp::options::WriteStream(stream.get()));
try {
curl_request->perform();
} catch (std::exception &ex) {
error = true;
std::cerr << "caught Unknown error: " << ex.what() << std::endl;
}
编辑流是字符串流,我使用的是 MS VS 2008
【问题讨论】:
-
什么操作系统?是 32 位还是 64 位?
-
您是否将 CURLOPT_VERBOSE 和 CURLOPT_HEADER 设置为 1 以查看实际从服务器返回的内容? 2GB 限制似乎非常熟悉作为 HTTP 特定问题(早在 1990 年代,很多文件系统都有 2GB 限制,所以我认为人们认为这是一个可以接受的限制)。