1
0
mirror of synced 2025-12-18 16:34:09 +03:00

Refactor ETag comparison logic and add test for If-None-Match with non-existent file

This commit is contained in:
yhirose
2025-12-05 15:54:32 -05:00
parent ef2b0a8d0b
commit 33e0bbfb35
2 changed files with 23 additions and 19 deletions

View File

@@ -8473,12 +8473,8 @@ inline bool Server::check_if_not_modified(const Request &req, Response &res,
// simplified implementation requires exact matches.
auto ret = detail::split_find(val.data(), val.data() + val.size(), ',',
[&](const char *b, const char *e) {
auto len = static_cast<size_t>(e - b);
if (len == 1 && *b == '*') return true;
if (len == etag.size() &&
std::equal(b, e, etag.begin()))
return true;
return false;
return std::equal(b, e, "*") ||
std::equal(b, e, etag.begin());
});
if (ret) {