summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2021-09-16 22:02:26 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2021-09-16 22:40:05 +0200
commit1edf8551cef0a7db7fdcdd5d6b06aec2ea7bb70d (patch)
treebefc66005cda8b145949497fcf49ffe6f4ffc496
parentd013f8957c0d464e0059cc107ca79d887cf9f8aa (diff)
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.
-rwxr-xr-xtest/integration/test-http-if-range15
-rw-r--r--test/interactive-helper/aptwebserver.cc2
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)