grpc.io

21 views
Skip to first unread message

Аркадий Руденко

unread,
May 12, 2025, 9:26:57 AMMay 12
to grpc.io
How can the C++ server detect the compression algorithm of the client (request)?

There are two contexts: `grpc::ServerContext` and `grpc::ClientContext`. Each context has methods: `compression_algorithm` (getter) and `set_compression_algorithm`.

If the client sets algo by `set_compression_algorithm` it used to compress requests. If the server sets algo by `set_compression_algorithm` it used to compress responses ([docs][1]). But how to check algo of the request on the server side?

`set_compression_algorithm` [adds metadata][2] in the header `grpc-internal-encoding-request`. But it is a internal metadata and this is not available in `grpc::ServerContext::client_metadata`

Generally, I want to get compress algo of a client on the server side and set the same algo for responses.


  [1]: https://grpc.github.io/grpc/cpp/classgrpc_1_1_server_context.html#a79723d2154ae4a48da5bef8daf41a3e7
  [2]: https://github.com/grpc/grpc/blob/2f8af1b7f2ac17793e01bec1b2654ca12ed21966/src/cpp/client/client_context.cc#L150
Reply all
Reply to author
Forward
0 new messages