aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/interop/interop_server.cc
diff options
context:
space:
mode:
authorGravatar Makarand Dharmapurikar <makarandd@google.com>2016-09-14 15:01:16 -0700
committerGravatar Makarand Dharmapurikar <makarandd@google.com>2016-09-14 15:01:16 -0700
commit1ed0b8e3d72abcc4788e89cab4caa4e8c0083985 (patch)
tree304e0cefda1020d57d878208b5614f0cc6d0670d /test/cpp/interop/interop_server.cc
parent83374d51662899adc08966ccca0d8d407f626df2 (diff)
Add interop test for Cacheable Unary Calls
modified interop test spec doc added CacheableUnaryCall to test.proto modified server and client implmenentations to support new method
Diffstat (limited to 'test/cpp/interop/interop_server.cc')
-rw-r--r--test/cpp/interop/interop_server.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc
index e5878bb248..ac2567eba0 100644
--- a/test/cpp/interop/interop_server.cc
+++ b/test/cpp/interop/interop_server.cc
@@ -47,6 +47,7 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
+#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/byte_stream.h"
#include "src/proto/grpc/testing/empty.grpc.pb.h"
#include "src/proto/grpc/testing/messages.grpc.pb.h"
@@ -152,6 +153,16 @@ class TestServiceImpl : public TestService::Service {
return Status::OK;
}
+ // Response contains current timestamp. We ignore everything in the request.
+ Status CacheableUnaryCall(ServerContext* context, const SimpleRequest* request,
+ SimpleResponse* response) {
+ gpr_timespec ts = gpr_now(GPR_CLOCK_REALTIME);
+ std::string timestamp = std::to_string(ts.tv_nsec);
+ response->mutable_payload()->set_body(timestamp.c_str(), timestamp.size());
+ context->AddInitialMetadata("Cache-Control", "max-age=100000, public");
+ return Status::OK;
+ }
+
Status UnaryCall(ServerContext* context, const SimpleRequest* request,
SimpleResponse* response) {
MaybeEchoMetadata(context);