Expose :authority pseudo-header to Obj-C API.

pull/11660/head
thassss 8 years ago committed by Muxi Yan
parent 06543fdce7
commit 69d7bd67f4
  1. 5
      src/objective-c/GRPCClient/GRPCCall.h
  2. 2
      src/objective-c/GRPCClient/GRPCCall.m
  3. 1
      src/objective-c/GRPCClient/private/GRPCChannel.h
  4. 5
      src/objective-c/GRPCClient/private/GRPCChannel.m
  5. 1
      src/objective-c/GRPCClient/private/GRPCHost.h
  6. 4
      src/objective-c/GRPCClient/private/GRPCHost.m
  7. 1
      src/objective-c/GRPCClient/private/GRPCWrappedCall.h
  8. 5
      src/objective-c/GRPCClient/private/GRPCWrappedCall.m

@ -178,6 +178,11 @@ extern id const kGRPCTrailersKey;
/** Represents a single gRPC remote call. */
@interface GRPCCall : GRXWriter
/**
* The server name for the RPC. If nil, the host name of the service object will be used instead.
*/
@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.

@ -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];

@ -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

@ -196,14 +196,17 @@ static grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) {
}
- (grpc_call *)unmanagedCallWithPath:(NSString *)path
serverName:(NSString *)serverName
completionQueue:(GRPCCompletionQueue *)queue {
grpc_slice 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
&host_slice,
gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
grpc_slice_unref(host_slice);
grpc_slice_unref(path_slice);
return call;
}

@ -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:(nullable NSString *)serverName
completionQueue:(GRPCCompletionQueue *)queue;
// TODO: There's a race when a new RPC is coming through just as an existing one is getting

@ -135,6 +135,7 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
}
- (nullable grpc_call *)unmanagedCallWithPath:(NSString *)path
serverName:(nullable NSString *)serverName
completionQueue:(GRPCCompletionQueue *)queue {
GRPCChannel *channel;
// This is racing -[GRPCHost disconnect].
@ -144,7 +145,8 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
}
channel = _channel;
}
return [channel unmanagedCallWithPath:path completionQueue:queue];
NSString *name = serverName ? serverName : _address;
return [channel unmanagedCallWithPath:path serverName:name completionQueue:queue];
}
- (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCerts

@ -90,6 +90,7 @@
@interface GRPCWrappedCall : NSObject
- (instancetype)initWithHost:(NSString *)host
serverName:(nullable NSString *)serverName
path:(NSString *)path NS_DESIGNATED_INITIALIZER;
- (void)startBatchWithOperations:(NSArray *)ops errorHandler:(void(^)())errorHandler;

@ -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:(nullable 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;
}

Loading…
Cancel
Save