jpbarrette / curlpp

C++ wrapper around libcURL
http://www.curlpp.org
1.68k stars 360 forks source link

abnormal upload speed and size #156

Open xuyiqun-learner opened 1 year ago

xuyiqun-learner commented 1 year ago

I had fetch the upload speed but the value is very very large. anyone knows why? the upload file size is 89.94M. here is the print speed_upload: 0 size of upload : 0 speed_upload: 0 size of upload : 0 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 2291k 0:00:02 0:00:02 --:--:-- 2291kspeed_upload: 4.70229e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 507k 0:00:10 0:00:10 --:--:-- 507kspeed_upload: 4.69268e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 2506k 0:00:02 0:00:02 --:--:-- 2507kspeed_upload: 4.70277e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 1920k 0:00:02 0:00:02 --:--:-- 1920kspeed_upload: 4.7012e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 1884k 0:00:02 0:00:02 --:--:-- 1884kspeed_upload: 4.70104e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 479k 0:00:10 0:00:10 --:--:-- 479kspeed_upload: 4.69218e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 445k 0:00:11 0:00:11 --:--:-- 445kspeed_upload: 4.69158e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 2532k 0:00:02 0:00:02 --:--:-- 2532kspeed_upload: 4.70282e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 488k 0:00:10 0:00:10 --:--:-- 488kspeed_upload: 4.69234e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 2581k 0:00:01 0:00:01 --:--:-- 2580kspeed_upload: 4.70293e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 1800k 0:00:02 0:00:02 --:--:-- 1800kspeed_upload: 4.70067e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 1952k 0:00:02 0:00:02 --:--:-- 1952kspeed_upload: 4.70134e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 1850k 0:00:02 0:00:02 --:--:-- 1849kspeed_upload: 4.70089e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 419k 0:00:12 0:00:12 --:--:-- 419kspeed_upload: 4.69112e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 2497k 0:00:02 0:00:02 --:--:-- 2497kspeed_upload: 4.70275e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 547k 0:00:09 0:00:09 --:--:-- 547kspeed_upload: 4.69307e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5120k 0 0 100 5120k 0 550k 0:00:09 0:00:09 --:--:-- 550kspeed_upload: 4.69309e+18 size of upload : 4.70739e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 5059k 0 0 100 5059k 0 512k 0:00:09 0:00:09 --:--:-- 512kspeed_upload: 4.69276e+18 size of upload : 4.70732e+18 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1875 100 267 100 1608 1931 11631 --:--:-- --:--:-- --:--:-- 13586speed_upload: 4.66762e+18 size of upload : 4.65479e+18 this is the part of my code minio::http::Response minio::http::Request::execute() { curlpp::Cleanup cleaner; curlpp::Easy request; curlpp::Multi requests;

// Request settings. request.setOpt( new curlpp::options::CustomRequest{http::MethodToString(method)}); std::string urlstring = url.String(); request.setOpt(new curlpp::Options::Url(urlstring)); if (debug) request.setOpt(new curlpp::Options::Verbose(true)); if (ignore_cert_check) { request.setOpt(new curlpp::Options::SslVerifyPeer(false)); }

if (url.https) { if (!ssl_cert_file.empty()) { request.setOpt(new curlpp::Options::SslVerifyPeer(true)); request.setOpt(new curlpp::Options::CaInfo(ssl_cert_file)); } if (!key_file.empty()) { request.setOpt(new curlpp::Options::SslKey(key_file)); } if (!cert_file.empty()) { request.setOpt(new curlpp::Options::SslCert(cert_file)); } }

utils::CharBuffer charbuf((char *)body.data(), body.size()); std::istream body_stream(&charbuf);

// using namespace std::placeholders; // request.setOpt(new curlpp::options::NoProgress(false)); // xyq // request.setOpt(new curlpp::options::ProgressFunction( // std::bind(&Response::ProgressCallback, &response, _1, _2, _3, _4))); // xyq

switch (method) { case Method::kDelete: case Method::kGet: break; case Method::kHead: request.setOpt(new curlpp::options::NoBody(true)); break; case Method::kPut: case Method::kPost: if (!headers.Contains("Content-Length")) { headers.Add("Content-Length", std::to_string(body.size())); } request.setOpt(new curlpp::Options::ReadStream(&body_stream)); request.setOpt(new curlpp::Options::InfileSize(body.size())); request.setOpt(new curlpp::Options::Upload(true)); break; }

std::list<std::string> headerlist = headers.ToHttpHeaders(); headerlist.push_back("Expect:"); // Disable 100 continue from server. request.setOpt(new curlpp::Options::HttpHeader(headerlist));

// Response settings. request.setOpt(new curlpp::options::Header(true));

Response response; response.datafunc = datafunc; response.userdata = userdata;

using namespace std::placeholders; request.setOpt(new curlpp::options::WriteFunction( std::bind(&Response::ResponseCallback, &response, &requests, &request, _1, _2, _3)));

request.setOpt(new curlpp::options::NoProgress(false)); // xyq request.setOpt(new curlpp::options::ProgressFunction( // xyq [&](double, double, double ultotal, double ulnow) -> int { if (ultotal > -0.1 && ultotal < 0.1) { return 0; } int ulPos = (int) ((ulnow/ultotal)*100); // std::cout << "ulnow: " << (int)ulnow << std::endl; // std::cout << "ultotal: " << (int)ultotal << std::endl; // std::cout << "progress value : " << ulPos << std::endl; // this->upload_progress = ulPos; return CURL_PROGRESSFUNC_CONTINUE; }));

int left = 0; requests.add(&request);

// Execute. while (!requests.perform(&left)) { } while (left) { fd_set fdread; fd_set fdwrite; fd_set fdexcep; int maxfd = 0;

FD_ZERO(&fdread); FD_ZERO(&fdwrite); FD_ZERO(&fdexcep);

requests.fdset(&fdread, &fdwrite, &fdexcep, &maxfd);

if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, NULL) < 0) { std::cerr << "select() failed; this should not happen" << std::endl; std::terminate(); } while (!requests.perform(&left)) { } } double speed_upload = 0; // xyq curlpp::infos::SpeedUpload::get(request, speed_upload); // xyq std::cout << "speed_upload: " << (speed_upload) << std::endl; // xyq double size_upload = 0; // xyq curlpp::infos::SizeUpload::get(request, size_upload); // xyq std::cout << "size of upload : " << size_upload << std::endl; // xyq

return response; }

xuyiqun-learner commented 1 year ago

I had seen the same issue https://github.com/jpbarrette/curlpp/issues/49, is solved yet? the version I used is 0.7.4

xuyiqun-learner commented 1 year ago

I clone the lastest repo code and recompile to use, it's already ok .

xuyiqun-learner commented 1 year ago

the reason is that downloaded repo by vcpkg is not up-to-date in the miniocpp