grpcpp/test/server_context_test_spouse.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPCPP_TEST_SERVER_CONTEXT_TEST_SPOUSE_H
20 #define GRPCPP_TEST_SERVER_CONTEXT_TEST_SPOUSE_H
21 
22 #include <map>
23 
24 #include <grpcpp/server_context.h>
25 
26 namespace grpc {
27 namespace testing {
28 
31  public:
33 
38  std::pair<std::string, std::string>(key, value));
39  ctx_->client_metadata_.map()->clear();
40  for (const auto& item : client_metadata_storage_) {
41  ctx_->client_metadata_.map()->insert(
42  std::pair<grpc::string_ref, grpc::string_ref>(
43  item.first.c_str(),
44  grpc::string_ref(item.second.data(), item.second.size())));
45  }
46  }
47 
48  std::multimap<std::string, std::string> GetInitialMetadata() const {
49  return ctx_->initial_metadata_;
50  }
51 
52  std::multimap<std::string, std::string> GetTrailingMetadata() const {
53  return ctx_->trailing_metadata_;
54  }
55 
56  private:
57  ServerContext* ctx_; // not owned
58  std::multimap<std::string, std::string> client_metadata_storage_;
59 };
60 
61 } // namespace testing
62 } // namespace grpc
63 
64 #endif // GRPCPP_TEST_SERVER_CONTEXT_TEST_SPOUSE_H
grpc::string_ref
Definition: grpcpp/impl/codegen/string_ref.h:43
testing
Definition: aws_request_signer_test.cc:25
grpc::ServerContext
Definition: grpcpp/impl/codegen/server_context.h:566
ctx
Definition: benchmark-async.c:30
grpc
Definition: grpcpp/alarm.h:33
grpc::ServerContextBase::trailing_metadata_
std::multimap< std::string, std::string > trailing_metadata_
Definition: grpcpp/impl/codegen/server_context.h:476
grpc::testing::ServerContextTestSpouse::AddClientMetadata
void AddClientMetadata(const std::string &key, const std::string &value)
Definition: grpcpp/test/server_context_test_spouse.h:36
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc::ServerContextBase::client_metadata_
grpc::internal::MetadataMap client_metadata_
Definition: grpcpp/impl/codegen/server_context.h:474
grpc::testing::ServerContextTestSpouse::ServerContextTestSpouse
ServerContextTestSpouse(ServerContext *ctx)
Definition: grpcpp/test/server_context_test_spouse.h:32
grpc::ServerContextBase::initial_metadata_
std::multimap< std::string, std::string > initial_metadata_
Definition: grpcpp/impl/codegen/server_context.h:475
grpc::testing::ServerContextTestSpouse::ctx_
ServerContext * ctx_
Definition: grpcpp/test/server_context_test_spouse.h:57
grpc::testing::ServerContextTestSpouse::GetInitialMetadata
std::multimap< std::string, std::string > GetInitialMetadata() const
Definition: grpcpp/test/server_context_test_spouse.h:48
grpc::testing::ServerContextTestSpouse::client_metadata_storage_
std::multimap< std::string, std::string > client_metadata_storage_
Definition: grpcpp/test/server_context_test_spouse.h:58
grpc::testing::ServerContextTestSpouse
A test-only class to access private members and methods of ServerContext.
Definition: grpcpp/test/server_context_test_spouse.h:30
value
const char * value
Definition: hpack_parser_table.cc:165
key
const char * key
Definition: hpack_parser_table.cc:164
server_context.h
grpc::testing::ServerContextTestSpouse::GetTrailingMetadata
std::multimap< std::string, std::string > GetTrailingMetadata() const
Definition: grpcpp/test/server_context_test_spouse.h:52
grpc::internal::MetadataMap::map
std::multimap< grpc::string_ref, grpc::string_ref > * map()
Definition: grpcpp/impl/codegen/metadata_map.h:68


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:11