use case-insensitive HTTP header matching per RFC 7230

This commit is contained in:
Łukasz Jerciński
2026-03-27 10:24:14 +01:00
parent 54ea2be8e0
commit 6ef0221f72
2 changed files with 17 additions and 5 deletions
+4 -4
View File
@@ -372,7 +372,7 @@ namespace http
void HTTPReq::UpdateHeader (const std::string& name, const std::string& value)
{
for (auto& it : headers)
if (it.first == name)
if (boost::iequals(it.first, name))
{
it.second = value;
break;
@@ -383,7 +383,7 @@ namespace http
{
for (auto it = headers.begin (); it != headers.end ();)
{
if (!it->first.compare(0, name.length (), name) && it->first != exempt)
if (boost::istarts_with(it->first, name) && !boost::iequals(it->first, exempt))
it = headers.erase (it);
else
it++;
@@ -393,7 +393,7 @@ namespace http
std::string HTTPReq::GetHeader (std::string_view name) const
{
for (auto& it : headers)
if (it.first == name)
if (boost::iequals(it.first, name))
return it.second;
return "";
}
@@ -402,7 +402,7 @@ namespace http
{
size_t num = 0;
for (auto& it : headers)
if (it.first == name) num++;
if (boost::iequals(it.first, name)) num++;
return num;
}