|  | @@ -20,9 +20,11 @@
 | 
	
		
			
				|  |  |  #include <limits.h>
 | 
	
		
			
				|  |  |  #include <string.h>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +#include "absl/container/inlined_vector.h"
 | 
	
		
			
				|  |  |  #include "absl/strings/match.h"
 | 
	
		
			
				|  |  |  #include "absl/strings/numbers.h"
 | 
	
		
			
				|  |  |  #include "absl/strings/str_cat.h"
 | 
	
		
			
				|  |  | +#include "absl/strings/str_join.h"
 | 
	
		
			
				|  |  |  #include "absl/strings/str_split.h"
 | 
	
		
			
				|  |  |  #include "absl/strings/string_view.h"
 | 
	
		
			
				|  |  |  #include "re2/re2.h"
 | 
	
	
		
			
				|  | @@ -227,21 +229,6 @@ class XdsRoutingLb : public LoadBalancingPolicy {
 | 
	
		
			
				|  |  |  // XdsRoutingLb::RoutePicker
 | 
	
		
			
				|  |  |  //
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -absl::optional<absl::string_view> GetMetadataValue(
 | 
	
		
			
				|  |  | -    const std::string& key,
 | 
	
		
			
				|  |  | -    LoadBalancingPolicy::MetadataInterface* initial_metadata) {
 | 
	
		
			
				|  |  | -  // TODO(roth): Using const auto& here trigger a warning in a macos or windows
 | 
	
		
			
				|  |  | -  // build:
 | 
	
		
			
				|  |  | -  //*(args.initial_metadata) is returning values not references.
 | 
	
		
			
				|  |  | -  GPR_DEBUG_ASSERT(initial_metadata != nullptr);
 | 
	
		
			
				|  |  | -  for (const auto p : *(initial_metadata)) {
 | 
	
		
			
				|  |  | -    if (p.first == key) {
 | 
	
		
			
				|  |  | -      return p.second;
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | -  return absl::nullopt;
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  bool PathMatch(
 | 
	
		
			
				|  |  |      const absl::string_view& path,
 | 
	
		
			
				|  |  |      const XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher& path_matcher) {
 | 
	
	
		
			
				|  | @@ -260,10 +247,32 @@ bool PathMatch(
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +absl::optional<absl::string_view> GetMetadataValue(
 | 
	
		
			
				|  |  | +    const std::string& key,
 | 
	
		
			
				|  |  | +    LoadBalancingPolicy::MetadataInterface* initial_metadata,
 | 
	
		
			
				|  |  | +    std::string* concatenated_value) {
 | 
	
		
			
				|  |  | +  // Find all values for the specified key.
 | 
	
		
			
				|  |  | +  GPR_DEBUG_ASSERT(initial_metadata != nullptr);
 | 
	
		
			
				|  |  | +  absl::InlinedVector<absl::string_view, 1> values;
 | 
	
		
			
				|  |  | +  for (const auto p : *initial_metadata) {
 | 
	
		
			
				|  |  | +    if (p.first == key) values.push_back(p.second);
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  // If none found, no match.
 | 
	
		
			
				|  |  | +  if (values.empty()) return absl::nullopt;
 | 
	
		
			
				|  |  | +  // If exactly one found, return it as-is.
 | 
	
		
			
				|  |  | +  if (values.size() == 1) return values.front();
 | 
	
		
			
				|  |  | +  // If more than one found, concatenate the values, using
 | 
	
		
			
				|  |  | +  // *concatenated_values as a temporary holding place for the
 | 
	
		
			
				|  |  | +  // concatenated string.
 | 
	
		
			
				|  |  | +  *concatenated_value = absl::StrJoin(values, ",");
 | 
	
		
			
				|  |  | +  return *concatenated_value;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  bool HeaderMatchHelper(
 | 
	
		
			
				|  |  |      const XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher& header_matcher,
 | 
	
		
			
				|  |  |      LoadBalancingPolicy::MetadataInterface* initial_metadata,
 | 
	
		
			
				|  |  |      const std::string& user_agent, absl::string_view deadline) {
 | 
	
		
			
				|  |  | +  std::string concatenated_value;
 | 
	
		
			
				|  |  |    absl::optional<absl::string_view> value;
 | 
	
		
			
				|  |  |    if (header_matcher.name == "grpc-tags-bin" ||
 | 
	
		
			
				|  |  |        header_matcher.name == "grpc-trace-bin" ||
 | 
	
	
		
			
				|  | @@ -276,7 +285,8 @@ bool HeaderMatchHelper(
 | 
	
		
			
				|  |  |    } else if (header_matcher.name == "grpc-timeout") {
 | 
	
		
			
				|  |  |      value = deadline;
 | 
	
		
			
				|  |  |    } else {
 | 
	
		
			
				|  |  | -    value = GetMetadataValue(header_matcher.name, initial_metadata);
 | 
	
		
			
				|  |  | +    value = GetMetadataValue(header_matcher.name, initial_metadata,
 | 
	
		
			
				|  |  | +                             &concatenated_value);
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    if (!value.has_value()) {
 | 
	
		
			
				|  |  |      if (header_matcher.type == XdsApi::RdsUpdate::RdsRoute::Matchers::
 |