Remove usage of some more metadata_batch apis (#27463)

* Remove usage of some more metadata_batch apis

* Automated change: Fix sanity tests

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
pull/27489/head
Craig Tiller 3 years ago committed by GitHub
parent 9b2b9976c6
commit 902836215a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/core/ext/filters/client_channel/client_channel.cc
  2. 3
      src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
  3. 3
      src/core/ext/filters/http/client/http_client_filter.cc
  4. 3
      src/core/ext/filters/http/server/http_server_filter.cc
  5. 2
      src/core/lib/security/authorization/evaluate_args.cc
  6. 4
      test/core/end2end/tests/filter_status_code.cc
  7. 8
      test/core/transport/metadata_test.cc

@ -2508,7 +2508,7 @@ class ClientChannel::LoadBalancedCall::Metadata
absl::optional<absl::string_view> Lookup(absl::string_view key,
std::string* buffer) const override {
return grpc_metadata_batch_get_value(batch_, key, buffer);
return batch_->GetValue(key, buffer);
}
private:

@ -597,8 +597,7 @@ absl::optional<absl::string_view> GetHeaderValue(
} else if (header_name == "content-type") {
return "application/grpc";
}
return grpc_metadata_batch_get_value(initial_metadata, header_name,
concatenated_value);
return initial_metadata->GetValue(header_name, concatenated_value);
}
bool HeadersMatch(const std::vector<HeaderMatcher>& header_matchers,

@ -355,8 +355,7 @@ static grpc_error_handle update_path_for_get(
grpc_mdelem_from_slices(GRPC_MDSTR_PATH, path_with_query_slice);
grpc_metadata_batch* b =
batch->payload->send_initial_metadata.send_initial_metadata;
return grpc_metadata_batch_substitute(b, b->legacy_index()->named.path,
mdelem_path_and_query);
return b->Substitute(b->legacy_index()->named.path, mdelem_path_and_query);
}
static void remove_if_present(grpc_metadata_batch* batch,

@ -291,8 +291,7 @@ static grpc_error_handle hs_filter_incoming_metadata(grpc_call_element* elem,
grpc_mdelem mdelem_path_without_query = grpc_mdelem_from_slices(
GRPC_MDSTR_PATH, grpc_slice_sub(path_slice, 0, offset));
grpc_metadata_batch_substitute(b, b->legacy_index()->named.path,
mdelem_path_without_query);
b->Substitute(b->legacy_index()->named.path, mdelem_path_without_query);
/* decode payload from query and add to the slice buffer to be returned */
const int k_url_safe = 1;

@ -130,7 +130,7 @@ absl::optional<absl::string_view> EvaluateArgs::GetHeaderValue(
if (metadata_ == nullptr) {
return absl::nullopt;
}
return grpc_metadata_batch_get_value(metadata_, key, concatenated_value);
return metadata_->GetValue(key, concatenated_value);
}
grpc_resolved_address EvaluateArgs::GetLocalAddress() const {

@ -265,8 +265,8 @@ static void server_start_transport_stream_op_batch(
auto* batch = op->payload->send_initial_metadata.send_initial_metadata;
if (batch->legacy_index()->named.status != nullptr) {
/* Replace the HTTP status with 404 */
grpc_metadata_batch_substitute(
batch, batch->legacy_index()->named.status, GRPC_MDELEM_STATUS_404);
batch->Substitute(batch->legacy_index()->named.status,
GRPC_MDELEM_STATUS_404);
}
}
}

@ -354,8 +354,8 @@ static void test_grpc_metadata_batch_get_value_with_absent_key(void) {
{
grpc_metadata_batch metadata;
std::string concatenated_value;
absl::optional<absl::string_view> value = grpc_metadata_batch_get_value(
&metadata, "absent_key", &concatenated_value);
absl::optional<absl::string_view> value =
metadata.GetValue("absent_key", &concatenated_value);
GPR_ASSERT(value == absl::nullopt);
}
grpc_shutdown();
@ -374,7 +374,7 @@ static void test_grpc_metadata_batch_get_value_returns_one_value(void) {
GPR_ASSERT(metadata.LinkHead(&storage) == GRPC_ERROR_NONE);
std::string concatenated_value;
absl::optional<absl::string_view> value =
grpc_metadata_batch_get_value(&metadata, kKey, &concatenated_value);
metadata.GetValue(kKey, &concatenated_value);
GPR_ASSERT(value.has_value());
GPR_ASSERT(value.value() == kValue);
}
@ -400,7 +400,7 @@ static void test_grpc_metadata_batch_get_value_returns_multiple_values(void) {
GPR_ASSERT(metadata.LinkTail(&storage2) == GRPC_ERROR_NONE);
std::string concatenated_value;
absl::optional<absl::string_view> value =
grpc_metadata_batch_get_value(&metadata, kKey, &concatenated_value);
metadata.GetValue(kKey, &concatenated_value);
GPR_ASSERT(value.has_value());
GPR_ASSERT(value.value() == absl::StrCat(kValue1, ",", kValue2));
}

Loading…
Cancel
Save