|
|
|
@ -68,7 +68,8 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
@implementation GRPCRequestOptions |
|
|
|
|
|
|
|
|
|
- (instancetype)initWithHost:(NSString *)host path:(NSString *)path safety:(GRPCCallSafety)safety { |
|
|
|
|
GRPCAssert(host.length != 0 && path.length != 0, NSInvalidArgumentException, @"Host and Path cannot be empty"); |
|
|
|
|
GRPCAssert(host.length != 0 && path.length != 0, NSInvalidArgumentException, |
|
|
|
|
@"Host and Path cannot be empty"); |
|
|
|
|
if ((self = [super init])) { |
|
|
|
|
_host = [host copy]; |
|
|
|
|
_path = [path copy]; |
|
|
|
@ -115,8 +116,10 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions |
|
|
|
|
responseHandler:(id<GRPCResponseHandler>)responseHandler |
|
|
|
|
callOptions:(GRPCCallOptions *_Nullable)callOptions { |
|
|
|
|
GRPCAssert(requestOptions.host.length != 0 && requestOptions.path.length != 0, NSInvalidArgumentException, @"Neither host nor path can be nil."); |
|
|
|
|
GRPCAssert(requestOptions.safety <= GRPCCallSafetyCacheableRequest, NSInvalidArgumentException, @"Invalid call safety value."); |
|
|
|
|
GRPCAssert(requestOptions.host.length != 0 && requestOptions.path.length != 0, |
|
|
|
|
NSInvalidArgumentException, @"Neither host nor path can be nil."); |
|
|
|
|
GRPCAssert(requestOptions.safety <= GRPCCallSafetyCacheableRequest, NSInvalidArgumentException, |
|
|
|
|
@"Invalid call safety value."); |
|
|
|
|
GRPCAssert(responseHandler != nil, NSInvalidArgumentException, @"Response handler required."); |
|
|
|
|
|
|
|
|
|
if ((self = [super init])) { |
|
|
|
@ -240,7 +243,8 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
- (void)writeData:(NSData *)data { |
|
|
|
|
dispatch_async(_dispatchQueue, ^{ |
|
|
|
|
GRPCAssert(!self->_canceled, NSInternalInconsistencyException, @"Call arleady canceled."); |
|
|
|
|
GRPCAssert(!self->_finished, NSInternalInconsistencyException, @"Call is half-closed before sending data."); |
|
|
|
|
GRPCAssert(!self->_finished, NSInternalInconsistencyException, |
|
|
|
|
@"Call is half-closed before sending data."); |
|
|
|
|
if (self->_call) { |
|
|
|
|
[self->_pipe writeValue:data]; |
|
|
|
|
} |
|
|
|
@ -400,8 +404,10 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
callOptions:(GRPCCallOptions *)callOptions { |
|
|
|
|
// Purposely using pointer rather than length ([host length] == 0) for backwards compatibility. |
|
|
|
|
GRPCAssert(host && path, NSInvalidArgumentException, @"Neither host nor path can be nil."); |
|
|
|
|
GRPCAssert(safety <= GRPCCallSafetyCacheableRequest, NSInvalidArgumentException, @"Invalid call safety value."); |
|
|
|
|
GRPCAssert(requestWriter.state == GRXWriterStateNotStarted, NSInvalidArgumentException, @"The requests writer can't be already started."); |
|
|
|
|
GRPCAssert(safety <= GRPCCallSafetyCacheableRequest, NSInvalidArgumentException, |
|
|
|
|
@"Invalid call safety value."); |
|
|
|
|
GRPCAssert(requestWriter.state == GRXWriterStateNotStarted, NSInvalidArgumentException, |
|
|
|
|
@"The requests writer can't be already started."); |
|
|
|
|
if ((self = [super init])) { |
|
|
|
|
_host = [host copy]; |
|
|
|
|
_path = [path copy]; |
|
|
|
@ -786,7 +792,9 @@ const char *kCFStreamVarName = "grpc_cfstream"; |
|
|
|
|
_callOptions = callOptions; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
GRPCAssert(_callOptions.authTokenProvider == nil || _callOptions.oauth2AccessToken == nil, NSInvalidArgumentException, @"authTokenProvider and oauth2AccessToken cannot be set at the same time"); |
|
|
|
|
GRPCAssert(_callOptions.authTokenProvider == nil || _callOptions.oauth2AccessToken == nil, |
|
|
|
|
NSInvalidArgumentException, |
|
|
|
|
@"authTokenProvider and oauth2AccessToken cannot be set at the same time"); |
|
|
|
|
if (_callOptions.authTokenProvider != nil) { |
|
|
|
|
@synchronized(self) { |
|
|
|
|
self.isWaitingForToken = YES; |
|
|
|
|