Skip to content

Commit 2207675

Browse files
committed
fix test_traceparent_header_name_valid_casing
1 parent 5e62859 commit 2207675

File tree

1 file changed

+21
-3
lines changed
  • ext/test/w3c_tracecontext_test

1 file changed

+21
-3
lines changed

ext/test/w3c_tracecontext_test/main.cc

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ class TextMapCarrierTest : public context::propagation::TextMapCarrier
5151
TextMapCarrierTest(std::map<std::string, std::string> &headers) : headers_(headers) {}
5252
nostd::string_view Get(nostd::string_view key) const noexcept override
5353
{
54-
auto it = headers_.find(std::string(key));
55-
if (it != headers_.end())
54+
for(const auto& elem : headers_)
5655
{
57-
return nostd::string_view(it->second);
56+
if (equalsIgnoreCase(elem.first, std::string(key)))
57+
{
58+
return nostd::string_view(elem.second);
59+
}
5860
}
5961
return "";
6062
}
@@ -63,6 +65,22 @@ class TextMapCarrierTest : public context::propagation::TextMapCarrier
6365
headers_[std::string(key)] = std::string(value);
6466
}
6567

68+
static bool equalsIgnoreCase(const std::string &str1, const std::string &str2)
69+
{
70+
if (str1.length() != str2.length())
71+
{
72+
return false;
73+
}
74+
for (int i = 0; i < str1.length(); i++)
75+
{
76+
if (tolower(str1[i]) != tolower(str2[i]))
77+
{
78+
return false;
79+
}
80+
}
81+
return true;
82+
}
83+
6684
std::map<std::string, std::string> &headers_;
6785
};
6886

0 commit comments

Comments
 (0)