diff options
author | makdharma <makdharma@users.noreply.github.com> | 2016-10-12 10:53:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-12 10:53:56 -0700 |
commit | 5ef0c0041fa09d9db030fea16a9d4b4794a2521f (patch) | |
tree | 347e6099991f7e6d2d38483586cb05a23556c683 /test/cpp/interop/interop_server.cc | |
parent | fad04cc4adb9607ff6e0e14fa863e581c5574124 (diff) | |
parent | 82d7677ec9104e6e3bf57097591ef322758e6cfb (diff) |
Merge pull request #8101 from makdharma/cacheable_unary
Add interop test for Cacheable Unary Calls
Diffstat (limited to 'test/cpp/interop/interop_server.cc')
-rw-r--r-- | test/cpp/interop/interop_server.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc index c05eb5d146..05af18bc67 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" @@ -153,6 +154,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_PRECISE); + std::string timestamp = std::to_string((long long unsigned)ts.tv_nsec); + response->mutable_payload()->set_body(timestamp.c_str(), timestamp.size()); + context->AddInitialMetadata("cache-control", "max-age=60, public"); + return Status::OK; + } + Status UnaryCall(ServerContext* context, const SimpleRequest* request, SimpleResponse* response) { MaybeEchoMetadata(context); |