Line data Source code
1 : #include "source/common/http/http1/header_formatter.h" 2 : 3 : #include <string> 4 : 5 : namespace Envoy { 6 : namespace Http { 7 : namespace Http1 { 8 0 : std::string ProperCaseHeaderKeyFormatter::format(absl::string_view key) const { 9 0 : auto copy = std::string(key); 10 : 11 0 : bool should_capitalize = true; 12 0 : for (char& c : copy) { 13 0 : if (should_capitalize && isalpha(c)) { 14 0 : c = static_cast<char>(toupper(c)); 15 0 : } 16 : 17 0 : should_capitalize = !isalpha(c) && !isdigit(c); 18 0 : } 19 : 20 0 : return copy; 21 0 : } 22 : } // namespace Http1 23 : } // namespace Http 24 : } // namespace Envoy