1
#include "source/common/http/http1/header_formatter.h"
2

            
3
#include <string>
4

            
5
namespace Envoy {
6
namespace Http {
7
namespace Http1 {
8
30
std::string ProperCaseHeaderKeyFormatter::format(absl::string_view key) const {
9
30
  auto copy = std::string(key);
10

            
11
30
  bool should_capitalize = true;
12
375
  for (char& c : copy) {
13
375
    if (should_capitalize && isalpha(c)) {
14
73
      c = static_cast<char>(toupper(c));
15
73
    }
16

            
17
375
    should_capitalize = !isalpha(c) && !isdigit(c);
18
375
  }
19

            
20
30
  return copy;
21
30
}
22
} // namespace Http1
23
} // namespace Http
24
} // namespace Envoy