Updates: when an answer is the rest of the same file, and how long to try

For carrying on a download that broke (issue #54): the head's ETag and
Content-Range are read, a 206 is checked to be the rest of the same
file, and a policy says how many tries a download is worth. Host-tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0162FokPdvY2KsS4NBfwyWPk
This commit is contained in:
2026-10-11 18:26:39 +02:00
co-authored by Claude Opus 5.5
parent 7e14e270df
commit 468dc0dc0d
4 changed files with 159 additions and 0 deletions
+11
View File
@@ -1,5 +1,7 @@
#include "http_head.h"
#include <cstdio>
#include <algorithm>
#include <cctype>
#include <cstdlib>
@@ -58,6 +60,15 @@ void HttpHeadParser::line() {
else if (name == "transfer-encoding") head_.chunked = lower(value).find("chunked") != std::string::npos;
else if (name == "location") head_.location = value;
else if (name == "content-type") head_.contentType = value;
else if (name == "etag") head_.etag = value;
else if (name == "content-range") {
long from = -1, to = -1, total = -1;
if (std::sscanf(lower(value).c_str(), "bytes %ld-%ld/%ld", &from, &to, &total) == 3 && from >= 0 && to >= from && total > to) {
head_.rangeFrom = from;
head_.rangeTo = to;
head_.rangeTotal = total;
}
}
}
size_t ChunkedDecoder::decode(const uint8_t* in, size_t len, uint8_t* out) {