Skip to content

Commit be08553

Browse files
authored
Fix HeaderAcceptField comp (#6762)
1 parent 7ddba23 commit be08553

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

include/ccf/http_accept.h

+4-11
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,21 @@ namespace ccf::http
4545

4646
bool operator<(const AcceptHeaderField& other) const
4747
{
48-
if (q_factor != other.q_factor)
48+
static constexpr auto float_comp_epsilon = 0.0000001f;
49+
if (abs(q_factor - other.q_factor) > float_comp_epsilon)
4950
{
5051
return q_factor < other.q_factor;
5152
}
5253

53-
if (is_wildcard(mime_type))
54+
if (is_wildcard(mime_type) && !is_wildcard(other.mime_type))
5455
{
5556
return true;
5657
}
57-
else if (is_wildcard(other.mime_type))
58-
{
59-
return false;
60-
}
6158

62-
if (is_wildcard(mime_subtype))
59+
if (is_wildcard(mime_subtype) && !is_wildcard(other.mime_subtype))
6360
{
6461
return true;
6562
}
66-
else if (is_wildcard(other.mime_subtype))
67-
{
68-
return false;
69-
}
7063

7164
// Spec says these mime types are now equivalent. For stability, we
7265
// order them lexicographically

0 commit comments

Comments
 (0)