Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/envoy/utils/http_header_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ absl::string_view readHeaderEntry(const Envoy::Http::HeaderEntry* entry) {
return Envoy::EMPTY_STRING;
}

absl::string_view extractHeader(const Envoy::Http::HeaderMap& headers,
const Envoy::Http::LowerCaseString& header) {
std::string extractHeader(const Envoy::Http::HeaderMap& headers,
const Envoy::Http::LowerCaseString& header) {
const auto result =
Envoy::Http::HeaderUtility::getAllOfHeaderAsString(headers, header);
if (!result.result().has_value()) {
return Envoy::EMPTY_STRING;
}
return result.result().value();
// When the header has multiple values, result().value() points into the
// local result's backing string, so it must be copied out before result
// goes out of scope.
return std::string(result.result().value());
}

bool handleHttpMethodOverride(Envoy::Http::RequestHeaderMap& headers) {
Expand Down
4 changes: 2 additions & 2 deletions src/envoy/utils/http_header_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ absl::string_view readHeaderEntry(const Envoy::Http::HeaderEntry* entry);
// better performance.
// For details, see
// https://github.com/envoyproxy/envoy/blob/c5f4302325223765b660f0f366ce25bf8570e7a5/include/envoy/http/header_map.h#L271
absl::string_view extractHeader(const Envoy::Http::HeaderMap& headers,
const Envoy::Http::LowerCaseString& header);
std::string extractHeader(const Envoy::Http::HeaderMap& headers,
const Envoy::Http::LowerCaseString& header);

// Get the HTTP method to be used for the request. This method understands the
// x-http-method-override header. If present, it will override the method
Expand Down