From 1edf8551cef0a7db7fdcdd5d6b06aec2ea7bb70d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 16 Sep 2021 22:02:26 +0200 Subject: Use exact If-Range match in our test webserver RFC7233 3.2 If-Range specifies the comparison to be an exact match, not a less or equal, which makes no sense in this context anyhow. Our server exists only to write our tests against it so this isn't much of a practical issue. I did confirm with a crashing server that no test (silently) depends on this or exhibits a different behaviour not explicitly checked for. --- test/integration/test-http-if-range | 15 ++++++++++++--- test/interactive-helper/aptwebserver.cc | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/test/integration/test-http-if-range b/test/integration/test-http-if-range index ca9f3b2e6..462d731cf 100755 --- a/test/integration/test-http-if-range +++ b/test/integration/test-http-if-range @@ -31,7 +31,11 @@ validpartialfile() { head -n 5 "$TESTFILE" > "$DOWNFILE" touch -d "$(stat --format '%y' "${TESTFILE}")" "$DOWNFILE" } -badpartialfile() { +badolderpartialfile() { + head -n 5 "$TESTFILE" > "$DOWNFILE" + touch -d "$(stat --format '%y' "${TESTFILE}") - 1sec" "$DOWNFILE" +} +badnewerpartialfile() { head -n 5 "$TESTFILE" > "$DOWNFILE" touch -d 'now + 1hour' "$DOWNFILE" } @@ -52,8 +56,13 @@ testrun() { testwebserverlaststatuscode "$3" "$DOWNLOADLOG" testsuccess cmp "$TESTFILE" "$DOWNFILE" - badpartialfile - testdownloadfile "bad partial file $1" + badolderpartialfile + testdownloadfile "bad old partial file $1" + testwebserverlaststatuscode "$4" "$DOWNLOADLOG" + testsuccess cmp "$TESTFILE" "$DOWNFILE" + + badnewerpartialfile + testdownloadfile "bad new partial file $1" testwebserverlaststatuscode "$4" "$DOWNLOADLOG" testsuccess cmp "$TESTFILE" "$DOWNFILE" diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc index 58ba54f84..d4bac24d1 100644 --- a/test/interactive-helper/aptwebserver.cc +++ b/test/interactive-helper/aptwebserver.cc @@ -828,7 +828,7 @@ static void * handleClient(int const client, size_t const id) /*{{{*/ ifrange = LookupTag(*m, "If-Range", ""); bool validrange = (ifrange.empty() == true || (RFC1123StrToTime(ifrange, cache) == true && - cache <= data.ModificationTime())); + cache == data.ModificationTime())); // FIXME: support multiple byte-ranges (APT clients do not do this) if (condition.find(',') == std::string::npos) -- cgit v1.2.3-70-g09d2