diff --git a/src/libstore/download.cc b/src/libstore/download.cc index f80c9e45..f0ea1995 100644 --- a/src/libstore/download.cc +++ b/src/libstore/download.cc @@ -140,6 +140,7 @@ struct CurlDownloader : public Downloader size_t writeCallback(void * contents, size_t size, size_t nmemb) { size_t realSize = size * nmemb; + result.bodySize += realSize; if (request.dataCallback) request.dataCallback((char *) contents, realSize); else @@ -162,6 +163,7 @@ struct CurlDownloader : public Downloader auto ss = tokenizeString>(line, " "); status = ss.size() >= 2 ? ss[1] : ""; result.data = std::make_shared(); + result.bodySize = 0; encoding = ""; } else { auto i = line.find(':'); @@ -296,6 +298,7 @@ struct CurlDownloader : public Downloader curl_easy_setopt(req, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); result.data = std::make_shared(); + result.bodySize = 0; } void finish(CURLcode code) @@ -309,7 +312,7 @@ struct CurlDownloader : public Downloader result.effectiveUrl = effectiveUrlCStr; debug("finished %s of '%s'; curl status = %d, HTTP status = %d, body = %d bytes", - request.verb(), request.uri, code, httpStatus, result.data ? result.data->size() : 0); + request.verb(), request.uri, code, httpStatus, result.bodySize); if (code == CURLE_WRITE_ERROR && result.etag == request.expectedETag) { code = CURLE_OK; diff --git a/src/libstore/download.hh b/src/libstore/download.hh index da55df7a..ff38a287 100644 --- a/src/libstore/download.hh +++ b/src/libstore/download.hh @@ -38,6 +38,7 @@ struct DownloadResult std::string etag; std::string effectiveUrl; std::shared_ptr data; + uint64_t bodySize = 0; }; class Store;