message: ext_authz: optimize header traversal in http client
diff: @@ -343,12 +343,11 @@ ResponsePtr RawHttpClientImpl::toResponse(Http::ResponseMessagePtr message) {
  // headers_to_remove in a variable first.
  std::vector<Http::LowerCaseString> headers_to_remove;
  if (status_code == enumToInt(Http::Code::OK)) {
  - // iterate() over the headers rather than just get() in case the storage
  - // header occurs more than once.
  - absl::string_view storage_header_name_view = absl::string_view(storage_header_name.get());
  - message->headers().iterate([&](const Http::HeaderEntry& entry) {
  - if (entry.key() == storage_header_name_view) {
  - absl::string_view storage_header_value = entry.value().getStringView();
  + const auto& get_result = message->headers().getAll(storage_header_name);
  + for (size_t i = 0; i < get_result.size(); ++i) {
  + const Http::HeaderEntry* entry = get_result[i];
  + if (entry != nullptr) {
  + absl::string_view storage_header_value = entry->value().getStringView();
  std::vector<absl::string_view> header_names = StringUtil::splitToken(
  storage_header_value, ",", /*keep_empty_string=*/false, /*trim_whitespace=*/true);
  headers_to_remove.reserve(headers_to_remove.size() + header_names.size());
  @@ -356,8 +355,7 @@ ResponsePtr RawHttpClientImpl::toResponse(Http::ResponseMessagePtr message) {
  headers_to_remove.push_back(Http::LowerCaseString(std::string(header_name)));
  }
  }
  - return Http::HeaderMap::Iterate::Continue;
  - });
  + }
  }
  // Now remove the storage header from the authz server response headers before
  // we reuse them to construct an Ok/Denied authorization response below.
  