diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-08-06T09·31+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2018-08-06T09·31+0200 |
commit | 4361a4331f1b2eb3fcfd954c96de353c9d516508 (patch) | |
tree | 100fdd9da05e6211645f72672cd6830f1a198c68 /src/libstore/download.cc | |
parent | 2825e05d21ecabc8b8524836baf0b9b05da993c6 (diff) |
Fix reporting of HTTP body size when a result callback is used
Diffstat (limited to 'src/libstore/download.cc')
-rw-r--r-- | src/libstore/download.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc index f80c9e45b82e..f0ea1995ae73 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<vector<string>>(line, " "); status = ss.size() >= 2 ? ss[1] : ""; result.data = std::make_shared<std::string>(); + 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<std::string>(); + 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; |