diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc index 6383f125944..125059c93a9 100644 --- a/src/core/ext/filters/http/client_authority_filter.cc +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -45,6 +45,7 @@ struct call_data { struct channel_data { grpc_slice default_authority; + grpc_mdelem default_authority_mdelem; }; void authority_start_transport_stream_op_batch( @@ -59,8 +60,7 @@ void authority_start_transport_stream_op_batch( initial_metadata->idx.named.authority == nullptr) { grpc_error* error = grpc_metadata_batch_add_head( initial_metadata, &calld->authority_storage, - grpc_mdelem_create(GRPC_MDSTR_AUTHORITY, chand->default_authority, - nullptr)); + GRPC_MDELEM_REF(chand->default_authority_mdelem)); if (error != GRPC_ERROR_NONE) { grpc_transport_stream_op_batch_finish_with_failure(batch, error, calld->call_combiner); @@ -103,6 +103,8 @@ grpc_error* init_channel_elem(grpc_channel_element* elem, } chand->default_authority = grpc_slice_intern(grpc_slice_from_static_string(default_authority_str)); + chand->default_authority_mdelem = grpc_mdelem_create( + GRPC_MDSTR_AUTHORITY, chand->default_authority, nullptr); GPR_ASSERT(!args->is_last); return GRPC_ERROR_NONE; } @@ -111,6 +113,7 @@ grpc_error* init_channel_elem(grpc_channel_element* elem, void destroy_channel_elem(grpc_channel_element* elem) { channel_data* chand = static_cast(elem->channel_data); grpc_slice_unref_internal(chand->default_authority); + GRPC_MDELEM_UNREF(chand->default_authority_mdelem); } } // namespace