aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2016-02-04 02:52:47 -0800
committerGravatar Jorge Canizales <jcanizales@google.com>2016-02-04 02:52:47 -0800
commitbe303e12cb8f9affe9dc022a13c33967eafabb33 (patch)
tree840e12b484e3448d009d93d81eafb4812675a18e /src/objective-c/GRPCClient
parent20b79e702db4cb811c67a1d9d199c0a462927fc5 (diff)
Add user agent of the library to that of the app.
Diffstat (limited to 'src/objective-c/GRPCClient')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCHost.m11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m
index 5b1ca16e12..f750841a44 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.m
+++ b/src/objective-c/GRPCClient/private/GRPCHost.m
@@ -40,6 +40,10 @@
#import "GRPCCompletionQueue.h"
#import "NSDictionary+GRPC.h"
+// TODO(jcanizales): Generate the version in a standalone header, from templates. Like
+// templates/src/core/surface/version.c.template .
+#define GRPC_OBJC_VERSION_STRING @"0.13.0"
+
@interface GRPCHost ()
// TODO(mlumish): Investigate whether caching channels with strong links is a good idea.
@property(nonatomic, strong) GRPCChannel *channel;
@@ -109,9 +113,14 @@
if (!_channel) {
NSMutableDictionary *args = [NSMutableDictionary dictionary];
+
+ // TODO(jcanizales): Add OS and device information (see
+ // https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#user-agents ).
+ NSString *userAgent = @"grpc-objc/" GRPC_OBJC_VERSION_STRING;
if (_userAgentPrefix) {
- args[@GRPC_ARG_PRIMARY_USER_AGENT_STRING] = _userAgentPrefix;
+ userAgent = [@[_userAgentPrefix, userAgent] componentsJoinedByString:@" "];
}
+ args[@GRPC_ARG_PRIMARY_USER_AGENT_STRING] = userAgent;
if (_secure) {
if (_hostNameOverride) {