aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/grpcpp/impl/codegen/client_context.h7
-rw-r--r--include/grpcpp/impl/codegen/client_interceptor.h15
-rw-r--r--include/grpcpp/impl/codegen/server_context.h14
-rw-r--r--include/grpcpp/impl/codegen/server_interceptor.h15
4 files changed, 47 insertions, 4 deletions
diff --git a/include/grpcpp/impl/codegen/client_context.h b/include/grpcpp/impl/codegen/client_context.h
index 0a71f3d9b6..5946488566 100644
--- a/include/grpcpp/impl/codegen/client_context.h
+++ b/include/grpcpp/impl/codegen/client_context.h
@@ -200,6 +200,13 @@ class ClientContext {
/// end in "-bin".
/// \param meta_value The metadata value. If its value is binary, the key name
/// must end in "-bin".
+ ///
+ /// Metadata must conform to the following format:
+ /// Custom-Metadata -> Binary-Header / ASCII-Header
+ /// Binary-Header -> {Header-Name "-bin" } {binary value}
+ /// ASCII-Header -> Header-Name ASCII-Value
+ /// Header-Name -> 1*( %x30-39 / %x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - .
+ /// ASCII-Value -> 1*( %x20-%x7E ) ; space and printable ASCII
void AddMetadata(const grpc::string& meta_key,
const grpc::string& meta_value);
diff --git a/include/grpcpp/impl/codegen/client_interceptor.h b/include/grpcpp/impl/codegen/client_interceptor.h
index 2eca596f1d..7dfe2290a3 100644
--- a/include/grpcpp/impl/codegen/client_interceptor.h
+++ b/include/grpcpp/impl/codegen/client_interceptor.h
@@ -38,9 +38,17 @@ class InterceptorBatchMethodsImpl;
namespace experimental {
class ClientRpcInfo;
+// A factory interface for creation of client interceptors. A vector of
+// factories can be provided at channel creation which will be used to create a
+// new vector of client interceptors per RPC. Client interceptor authors should
+// create a subclass of ClientInterceptorFactorInterface which creates objects
+// of their interceptors.
class ClientInterceptorFactoryInterface {
public:
virtual ~ClientInterceptorFactoryInterface() {}
+ // Returns a pointer to an Interceptor object on successful creation, nullptr
+ // otherwise. If nullptr is returned, this server interceptor factory is
+ // ignored for the purposes of that RPC.
virtual Interceptor* CreateClientInterceptor(ClientRpcInfo* info) = 0;
};
} // namespace experimental
@@ -135,8 +143,11 @@ class ClientRpcInfo {
}
for (auto it = creators.begin() + interceptor_pos; it != creators.end();
++it) {
- interceptors_.push_back(std::unique_ptr<experimental::Interceptor>(
- (*it)->CreateClientInterceptor(this)));
+ auto* interceptor = (*it)->CreateClientInterceptor(this);
+ if (interceptor != nullptr) {
+ interceptors_.push_back(
+ std::unique_ptr<experimental::Interceptor>(interceptor));
+ }
}
if (internal::g_global_client_interceptor_factory != nullptr) {
interceptors_.push_back(std::unique_ptr<experimental::Interceptor>(
diff --git a/include/grpcpp/impl/codegen/server_context.h b/include/grpcpp/impl/codegen/server_context.h
index ccb5925e7d..affe61b547 100644
--- a/include/grpcpp/impl/codegen/server_context.h
+++ b/include/grpcpp/impl/codegen/server_context.h
@@ -131,6 +131,13 @@ class ServerContext {
/// end in "-bin".
/// \param value The metadata value. If its value is binary, the key name
/// must end in "-bin".
+ ///
+ /// Metadata must conform to the following format:
+ /// Custom-Metadata -> Binary-Header / ASCII-Header
+ /// Binary-Header -> {Header-Name "-bin" } {binary value}
+ /// ASCII-Header -> Header-Name ASCII-Value
+ /// Header-Name -> 1*( %x30-39 / %x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - .
+ /// ASCII-Value -> 1*( %x20-%x7E ) ; space and printable ASCII
void AddInitialMetadata(const grpc::string& key, const grpc::string& value);
/// Add the (\a key, \a value) pair to the initial metadata
@@ -145,6 +152,13 @@ class ServerContext {
/// it must end in "-bin".
/// \param value The metadata value. If its value is binary, the key name
/// must end in "-bin".
+ ///
+ /// Metadata must conform to the following format:
+ /// Custom-Metadata -> Binary-Header / ASCII-Header
+ /// Binary-Header -> {Header-Name "-bin" } {binary value}
+ /// ASCII-Header -> Header-Name ASCII-Value
+ /// Header-Name -> 1*( %x30-39 / %x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - .
+ /// ASCII-Value -> 1*( %x20-%x7E ) ; space and printable ASCII
void AddTrailingMetadata(const grpc::string& key, const grpc::string& value);
/// IsCancelled is always safe to call when using sync or callback API.
diff --git a/include/grpcpp/impl/codegen/server_interceptor.h b/include/grpcpp/impl/codegen/server_interceptor.h
index 6664d09e4a..3e71b3fc55 100644
--- a/include/grpcpp/impl/codegen/server_interceptor.h
+++ b/include/grpcpp/impl/codegen/server_interceptor.h
@@ -37,9 +37,17 @@ class InterceptorBatchMethodsImpl;
namespace experimental {
class ServerRpcInfo;
+// A factory interface for creation of server interceptors. A vector of
+// factories can be provided to ServerBuilder which will be used to create a new
+// vector of server interceptors per RPC. Server interceptor authors should
+// create a subclass of ServerInterceptorFactorInterface which creates objects
+// of their interceptors.
class ServerInterceptorFactoryInterface {
public:
virtual ~ServerInterceptorFactoryInterface() {}
+ // Returns a pointer to an Interceptor object on successful creation, nullptr
+ // otherwise. If nullptr is returned, this server interceptor factory is
+ // ignored for the purposes of that RPC.
virtual Interceptor* CreateServerInterceptor(ServerRpcInfo* info) = 0;
};
@@ -104,8 +112,11 @@ class ServerRpcInfo {
std::unique_ptr<experimental::ServerInterceptorFactoryInterface>>&
creators) {
for (const auto& creator : creators) {
- interceptors_.push_back(std::unique_ptr<experimental::Interceptor>(
- creator->CreateServerInterceptor(this)));
+ auto* interceptor = creator->CreateServerInterceptor(this);
+ if (interceptor != nullptr) {
+ interceptors_.push_back(
+ std::unique_ptr<experimental::Interceptor>(interceptor));
+ }
}
}