22 [[nodiscard]]
const char*
what() const noexcept
override
35 bool any_value =
false;
37 std::set<std::string> if_etags;
46 if (match_header ==
"*")
52 std::regex etag_rx(R
"(\"([^\"]+)\",?\s*)");
54 std::sregex_iterator(match_header.begin(), match_header.end(), etag_rx);
55 auto etags_end = std::sregex_iterator();
56 ssize_t last_matched = 0;
58 for (std::sregex_iterator i = etags_begin; i != etags_end; ++i)
60 if (i->position() != last_matched)
64 const std::smatch& match = *i;
65 if_etags.insert(match[1].str());
66 last_matched = match.position() + match.length();
69 ssize_t last_index_in_header = match_header.size();
71 if (last_matched != last_index_in_header || if_etags.empty())
78 [[nodiscard]]
bool matches(
const std::string& etag)
const
80 return any_value || if_etags.contains(etag);
Definition http_etag.h:15
MatcherError(std::string msg_)
Definition http_etag.h:20
const char * what() const noexcept override
Definition http_etag.h:22
Definition http_etag.h:32
bool matches(const std::string &etag) const
Check if a given ETag matches the If-Match/If-None-Match header.
Definition http_etag.h:78
Matcher(const std::string &match_header)
Definition http_etag.h:44
bool is_any() const
Check if the header will match any ETag (*)
Definition http_etag.h:84
Definition http_accept.h:13