aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-12-09 19:11:59 +0100
committerGitHub Enterprise <[email protected]>2025-12-09 19:11:59 +0100
commit755be66329823dde3985bb25ecf4674fc003255f (patch)
tree11dfcf5f62097852f3fa83fcba61f20857713290 /src
parentupload to zen cache from oplog import now disabled by default (#680) (diff)
downloadzen-755be66329823dde3985bb25ecf4674fc003255f.tar.xz
zen-755be66329823dde3985bb25ecf4674fc003255f.zip
fix reading of stale iterator when doing download-resume (#681)
Diffstat (limited to 'src')
-rw-r--r--src/zenhttp/clients/httpclientcpr.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/zenhttp/clients/httpclientcpr.cpp b/src/zenhttp/clients/httpclientcpr.cpp
index 7bfc4670c..987cdd706 100644
--- a/src/zenhttp/clients/httpclientcpr.cpp
+++ b/src/zenhttp/clients/httpclientcpr.cpp
@@ -1038,6 +1038,15 @@ CprHttpClient::Download(std::string_view Url, const std::filesystem::path& TempF
auto It = Response.header.find("Content-Length");
if (It != Response.header.end())
{
+ uint64_t ContentLength = RequestedContentLength;
+ if (ContentLength == uint64_t(-1))
+ {
+ if (auto ParsedContentLength = ParseInt<int64_t>(It->second); ParsedContentLength.has_value())
+ {
+ ContentLength = ParsedContentLength.value();
+ }
+ }
+
std::vector<std::pair<std::string, std::string>> ReceivedHeaders;
auto HeaderCallback = [&](std::string header, intptr_t) {
@@ -1088,15 +1097,6 @@ CprHttpClient::Download(std::string_view Url, const std::filesystem::path& TempF
{
uint64_t DownloadedSize = PayloadFile ? PayloadFile->GetSize() : PayloadString.length();
- uint64_t ContentLength = RequestedContentLength;
- if (ContentLength == uint64_t(-1))
- {
- if (auto ParsedContentLength = ParseInt<int64_t>(It->second); ParsedContentLength.has_value())
- {
- ContentLength = ParsedContentLength.value();
- }
- }
-
std::string Range = fmt::format("bytes={}-{}", DownloadedSize, DownloadedSize + ContentLength - 1);
if (auto RangeIt = HeadersWithRange.Entries.find("Range"); RangeIt != HeadersWithRange.Entries.end())
{