aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Muxi Yan <muxi@users.noreply.github.com>2017-07-03 17:07:03 -0700
committerGravatar GitHub <noreply@github.com>2017-07-03 17:07:03 -0700
commitd5ed0ea971deb6daf014edb82d8ed04147d4e1f4 (patch)
tree34005b88024a9be1672c4d862c5412bf6cba7405 /src
parent06543fdce7d8c9f6962e40f9ee9e22fa1ecd24af (diff)
parent42301bfd0ea6f8881ca21c2e06a4474822f0f043 (diff)
Merge pull request #11660 from muxi/backport-11606
Backport #11606: Expose :authority pseudo-header to Obj-C API
Diffstat (limited to 'src')
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.h6
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.m2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.h1
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.m10
-rw-r--r--src/objective-c/GRPCClient/private/GRPCHost.h1
-rw-r--r--src/objective-c/GRPCClient/private/GRPCHost.m3
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.h1
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.m5
8 files changed, 24 insertions, 5 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h
index 5e9324c445..9a5a2a44d2 100644
--- a/src/objective-c/GRPCClient/GRPCCall.h
+++ b/src/objective-c/GRPCClient/GRPCCall.h
@@ -179,6 +179,12 @@ extern id const kGRPCTrailersKey;
@interface GRPCCall : GRXWriter
/**
+ * The authority for the RPC. If nil, the default authority will be used. This property must be nil
+ * when Cronet transport is enabled.
+ */
+@property (atomic, readwrite) NSString *serverName;
+
+/**
* The container of the request headers of an RPC conforms to this protocol, which is a subset of
* NSMutableDictionary's interface. It will become a NSMutableDictionary later on.
* The keys of this container are the header names, which per the HTTP standard are case-
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index f9d13fea57..cb505bd82d 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -440,7 +440,7 @@ static NSMutableDictionary *callFlags;
_responseWriteable = [[GRXConcurrentWriteable alloc] initWithWriteable:writeable
dispatchQueue:_responseQueue];
- _wrappedCall = [[GRPCWrappedCall alloc] initWithHost:_host path:_path];
+ _wrappedCall = [[GRPCWrappedCall alloc] initWithHost:_host serverName:_serverName path:_path];
NSAssert(_wrappedCall, @"Error allocating RPC objects. Low memory?");
[self sendHeaders:_requestHeaders];
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.h b/src/objective-c/GRPCClient/private/GRPCChannel.h
index 5bada2dd50..a7db866473 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.h
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.h
@@ -77,5 +77,6 @@ struct grpc_channel_credentials;
channelArgs:(nullable NSDictionary *)channelArgs;
- (nullable grpc_call *)unmanagedCallWithPath:(nonnull NSString *)path
+ serverName:(nonnull NSString *)serverName
completionQueue:(nonnull GRPCCompletionQueue *)queue;
@end
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m
index fcfaa4a134..d37c2b2a4e 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.m
@@ -196,14 +196,22 @@ static grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) {
}
- (grpc_call *)unmanagedCallWithPath:(NSString *)path
+ serverName:(NSString *)serverName
completionQueue:(GRPCCompletionQueue *)queue {
+ grpc_slice host_slice;
+ if (serverName) {
+ host_slice = grpc_slice_from_copied_string(serverName.UTF8String);
+ }
grpc_slice path_slice = grpc_slice_from_copied_string(path.UTF8String);
grpc_call *call = grpc_channel_create_call(_unmanagedChannel,
NULL, GRPC_PROPAGATE_DEFAULTS,
queue.unmanagedQueue,
path_slice,
- NULL, // Passing NULL for host
+ serverName ? &host_slice : NULL,
gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ if (serverName) {
+ grpc_slice_unref(host_slice);
+ }
grpc_slice_unref(path_slice);
return call;
}
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.h b/src/objective-c/GRPCClient/private/GRPCHost.h
index c8b5dd315b..1f74d5551f 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.h
+++ b/src/objective-c/GRPCClient/private/GRPCHost.h
@@ -69,6 +69,7 @@ struct grpc_channel_credentials;
/** Create a grpc_call object to the provided path on this host. */
- (nullable struct grpc_call *)unmanagedCallWithPath:(NSString *)path
+ serverName:(NSString *)serverName
completionQueue:(GRPCCompletionQueue *)queue;
// TODO: There's a race when a new RPC is coming through just as an existing one is getting
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m
index 246af560cd..13a9af9af5 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.m
+++ b/src/objective-c/GRPCClient/private/GRPCHost.m
@@ -135,6 +135,7 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
}
- (nullable grpc_call *)unmanagedCallWithPath:(NSString *)path
+ serverName:(NSString *)serverName
completionQueue:(GRPCCompletionQueue *)queue {
GRPCChannel *channel;
// This is racing -[GRPCHost disconnect].
@@ -144,7 +145,7 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
}
channel = _channel;
}
- return [channel unmanagedCallWithPath:path completionQueue:queue];
+ return [channel unmanagedCallWithPath:path serverName:serverName completionQueue:queue];
}
- (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCerts
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
index 52233c8242..171d2ec612 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
@@ -90,6 +90,7 @@
@interface GRPCWrappedCall : NSObject
- (instancetype)initWithHost:(NSString *)host
+ serverName:(NSString *)serverName
path:(NSString *)path NS_DESIGNATED_INITIALIZER;
- (void)startBatchWithOperations:(NSArray *)ops errorHandler:(void(^)())errorHandler;
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
index 06570c5ea2..dcdc5c55b1 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
@@ -251,10 +251,11 @@
}
- (instancetype)init {
- return [self initWithHost:nil path:nil];
+ return [self initWithHost:nil serverName:nil path:nil];
}
- (instancetype)initWithHost:(NSString *)host
+ serverName:(NSString *)serverName
path:(NSString *)path {
if (!path || !host) {
[NSException raise:NSInvalidArgumentException
@@ -267,7 +268,7 @@
// queue. Currently we use a singleton queue.
_queue = [GRPCCompletionQueue completionQueue];
- _call = [[GRPCHost hostWithAddress:host] unmanagedCallWithPath:path completionQueue:_queue];
+ _call = [[GRPCHost hostWithAddress:host] unmanagedCallWithPath:path serverName:serverName completionQueue:_queue];
if (_call == NULL) {
return nil;
}