From d7d9ce27c523798384051246e18e3f00b29dd8c9 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 30 Jun 2015 23:29:03 -0700 Subject: WIP in *_end2end_test.cc. Tests pass. Fixed leaks and introduced concept of compression request thru MD --- src/cpp/server/server_context.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/cpp/server') diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index 699895a3cf..087e28d33a 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -39,6 +39,8 @@ #include #include +#include "src/core/channel/compress_filter.h" + namespace grpc { // CompletionOp @@ -146,4 +148,22 @@ bool ServerContext::IsCancelled() { return completion_op_ && completion_op_->CheckCancelled(cq_); } +void ServerContext::set_compression_level(grpc_compression_level level) { + const grpc_compression_algorithm algorithm_for_level = + grpc_compression_algorithm_for_level(level); + set_compression_algorithm(algorithm_for_level); +} + +void ServerContext::set_compression_algorithm( + grpc_compression_algorithm algorithm) { + char* algorithm_name = NULL; + if (!grpc_compression_algorithm_name(algorithm, &algorithm_name)) { + gpr_log(GPR_ERROR, "Name for compression algorithm '%d' unknown.", + algorithm); + abort(); + } + GPR_ASSERT(algorithm_name != NULL); + AddInitialMetadata(GRPC_COMPRESS_REQUEST_ALGORITHM_KEY, algorithm_name); +} + } // namespace grpc -- cgit v1.2.3