我正在尝试使用 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