diff options
Diffstat (limited to 'src/objective-c/GRPCClient/private/GRPCHost.m')
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCHost.m | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index a8cd3a0e74..3ea89104d0 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -39,6 +39,7 @@ #import "GRPCCompletionQueue.h" #import "GRPCSecureChannel.h" #import "GRPCUnsecuredChannel.h" +#import "GRPCWrappedChannelArgs.h" @interface GRPCHost () // TODO(mlumish): Investigate whether caching channels with strong links is a good idea. @@ -107,12 +108,25 @@ // Create it lazily, because we don't want to open a connection just because someone is // configuring a host. if (!_channel) { + GRPCWrappedChannelArgsBuilder *argsBuilder = [[GRPCWrappedChannelArgsBuilder alloc] init]; + if (_primaryUserAgent) { + [argsBuilder addKey:@GRPC_ARG_PRIMARY_USER_AGENT_STRING stringValue:_primaryUserAgent]; + } + if (_secondaryUserAgent) { + [argsBuilder addKey:@GRPC_ARG_SECONDARY_USER_AGENT_STRING stringValue:_secondaryUserAgent]; + } + if (_secure) { + if (_hostNameOverride) { + [argsBuilder addKey:@GRPC_SSL_TARGET_NAME_OVERRIDE_ARG stringValue:_hostNameOverride]; + } + _channel = [[GRPCSecureChannel alloc] initWithHost:_address pathToCertificates:_pathToCertificates - hostNameOverride:_hostNameOverride]; + channelArgs:[argsBuilder build]]; } else { - _channel = [[GRPCUnsecuredChannel alloc] initWithHost:_address]; + _channel = [[GRPCUnsecuredChannel alloc] initWithHost:_address + channelArgs:[argsBuilder build]]; } } return _channel; |