aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/interop
diff options
context:
space:
mode:
authorGravatar Makarand Dharmapurikar <makarandd@google.com>2016-02-22 15:42:18 -0800
committerGravatar Makarand Dharmapurikar <makarandd@google.com>2016-02-22 15:42:18 -0800
commitbfc7adaa714b5d8a3b0dca4a25d572dbd92039be (patch)
tree1b2f97b6e45d44dc23065425e04f37c671ce0a96 /test/cpp/interop
parent31dd666054fb5221f5aad4ed77a9b375611d0512 (diff)
Added option to echo back user agent for testing
Diffstat (limited to 'test/cpp/interop')
-rw-r--r--test/cpp/interop/server.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/cpp/interop/server.cc b/test/cpp/interop/server.cc
index 63eca6a5ef..18ac35d551 100644
--- a/test/cpp/interop/server.cc
+++ b/test/cpp/interop/server.cc
@@ -82,6 +82,7 @@ static const char* kRandomFile = "test/cpp/interop/rnd.dat";
const char kEchoInitialMetadataKey[] = "x-grpc-test-echo-initial";
const char kEchoTrailingBinMetadataKey[] = "x-grpc-test-echo-trailing-bin";
+const char kEchoUserAgentKey[] = "x-grpc-test-echo-useragent";
void MaybeEchoMetadata(ServerContext* context) {
const auto& client_metadata = context->client_metadata();
@@ -98,6 +99,15 @@ void MaybeEchoMetadata(ServerContext* context) {
kEchoTrailingBinMetadataKey,
grpc::string(iter->second.begin(), iter->second.end()));
}
+ // Check if client sent a magic key in the header that makes us echo
+ // back the user-agent (for testing purpose)
+ iter = client_metadata.find(kEchoUserAgentKey);
+ if (iter != client_metadata.end()) {
+ iter = client_metadata.find("user-agent");
+ if (iter != client_metadata.end()) {
+ context->AddInitialMetadata(kEchoUserAgentKey, iter->second.data());
+ }
+ }
}
bool SetPayload(PayloadType type, int size, Payload* payload) {
@@ -150,6 +160,7 @@ class TestServiceImpl : public TestService::Service {
public:
Status EmptyCall(ServerContext* context, const grpc::testing::Empty* request,
grpc::testing::Empty* response) {
+ MaybeEchoMetadata(context);
return Status::OK;
}