aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2017-12-21 16:52:39 -0800
committerGravatar Muxi Yan <mxyan@google.com>2017-12-21 17:03:24 -0800
commitc47b3f5c3afa57ccb2bb64426f1aa91ecf6d4bfe (patch)
treeffc2af1410c6e27451682cc8ae3208e8677552bc /src/objective-c/GRPCClient/GRPCCall+ChannelArg.m
parentd55110b91571e362ddd1f78848a8a30ff61d3c47 (diff)
Add interface to API to enable compression
Diffstat (limited to 'src/objective-c/GRPCClient/GRPCCall+ChannelArg.m')
-rw-r--r--src/objective-c/GRPCClient/GRPCCall+ChannelArg.m20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m
index 398d98fbc7..0248f33638 100644
--- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m
+++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m
@@ -20,6 +20,8 @@
#import "private/GRPCHost.h"
+#import <grpc/impl/codegen/compression_types.h>
+
@implementation GRPCCall (ChannelArg)
+ (void)setUserAgentPrefix:(nonnull NSString *)userAgentPrefix forHost:(nonnull NSString *)host {
@@ -36,4 +38,22 @@
[GRPCHost flushChannelCache];
}
++ (void)setDefaultCompressMethod:(GRPCCompressAlgorithm)algorithm
+ forhost:(nonnull NSString *)host {
+ GRPCHost *hostConfig = [GRPCHost hostWithAddress:host];
+ switch (algorithm) {
+ case GRPCCompressNone:
+ hostConfig.compressAlgorithm = GRPC_COMPRESS_NONE;
+ break;
+ case GRPCCompressDeflate:
+ hostConfig.compressAlgorithm = GRPC_COMPRESS_DEFLATE;
+ break;
+ case GRPCCompressGzip:
+ hostConfig.compressAlgorithm = GRPC_COMPRESS_GZIP;
+ break;
+ default:
+ NSLog(@"Invalid compression algorithm");
+ }
+}
+
@end