diff options
Diffstat (limited to 'src/objective-c')
-rw-r--r-- | src/objective-c/GRPCClient/GRPCCall.h | 17 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/GRPCCall.m | 5 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCRequestHeaders.h (renamed from src/objective-c/GRPCClient/GRPCRequestHeaders.h) | 4 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCRequestHeaders.m (renamed from src/objective-c/GRPCClient/GRPCRequestHeaders.m) | 0 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCWrappedCall.h | 5 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCWrappedCall.m | 4 |
6 files changed, 23 insertions, 12 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 1487001da5..fc274a095f 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -48,13 +48,26 @@ #import <Foundation/Foundation.h> #import <RxLibrary/GRXWriter.h> -#import "GRPCRequestHeaders.h" +#include <grpc/grpc.h> // Keys used in |NSError|'s |userInfo| dictionary to store the response headers and trailers sent by // the server. extern id const kGRPCHeadersKey; extern id const kGRPCTrailersKey; +@protocol GRPCRequestHeaders <NSObject> + +@property(nonatomic, readonly) NSUInteger count; +@property(nonatomic, readonly) grpc_metadata *grpc_metadataArray; + +- (id)objectForKeyedSubscript:(NSString *)key; +- (void)setObject:(id)obj forKeyedSubscript:(NSString *)key; + +- (void)removeAllObjects; +- (void)removeObjectForKey:(NSString *)key; + +@end + // Represents a single gRPC remote call. @interface GRPCCall : GRXWriter @@ -72,7 +85,7 @@ extern id const kGRPCTrailersKey; // // For convenience, the property is initialized to an empty NSMutableDictionary, and the setter // accepts (and copies) both mutable and immutable dictionaries. -- (GRPCRequestHeaders *)requestHeaders; // nonatomic +- (id<GRPCRequestHeaders>)requestHeaders; // nonatomic - (void)setRequestHeaders:(NSDictionary *)requestHeaders; // nonatomic, copy // This dictionary is populated with the HTTP headers received from the server. This happens before diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index d5f775c6e6..1be753e688 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -37,6 +37,7 @@ #include <grpc/support/time.h> #import <RxLibrary/GRXConcurrentWriteable.h> +#import "private/GRPCRequestHeaders.h" #import "private/GRPCWrappedCall.h" #import "private/NSData+GRPC.h" #import "private/NSDictionary+GRPC.h" @@ -131,7 +132,7 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey"; #pragma mark Metadata -- (GRPCRequestHeaders *)requestHeaders { +- (id<GRPCRequestHeaders>)requestHeaders { return _requestHeaders; } @@ -234,7 +235,7 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey"; #pragma mark Send headers -- (void)sendHeaders:(GRPCRequestHeaders *)headers { +- (void)sendHeaders:(id<GRPCRequestHeaders>)headers { // TODO(jcanizales): Add error handlers for async failures [_wrappedCall startBatchWithOperations:@[[[GRPCOpSendMetadata alloc] initWithMetadata:headers handler:nil]]]; diff --git a/src/objective-c/GRPCClient/GRPCRequestHeaders.h b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h index 5a93f82cd8..066f71a8f6 100644 --- a/src/objective-c/GRPCClient/GRPCRequestHeaders.h +++ b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h @@ -34,9 +34,9 @@ #import <Foundation/Foundation.h> #include <grpc/grpc.h> -@class GRPCCall; +#import "GRPCCall.h" -@interface GRPCRequestHeaders : NSObject +@interface GRPCRequestHeaders : NSObject<GRPCRequestHeaders> @property(nonatomic, readonly) NSUInteger count; @property(nonatomic, readonly) grpc_metadata *grpc_metadataArray; diff --git a/src/objective-c/GRPCClient/GRPCRequestHeaders.m b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m index d4bbbdf84a..d4bbbdf84a 100644 --- a/src/objective-c/GRPCClient/GRPCRequestHeaders.m +++ b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h index ba34c0a6e7..9147ba0816 100644 --- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h +++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h @@ -35,8 +35,7 @@ #include <grpc/grpc.h> #import "GRPCChannel.h" - -@class GRPCRequestHeaders; +#import "GRPCCall.h" @interface GRPCOperation : NSObject @property(nonatomic, readonly) grpc_op op; @@ -46,7 +45,7 @@ @interface GRPCOpSendMetadata : GRPCOperation -- (instancetype)initWithMetadata:(GRPCRequestHeaders *)metadata +- (instancetype)initWithMetadata:(id<GRPCRequestHeaders>)metadata handler:(void(^)())handler NS_DESIGNATED_INITIALIZER; @end diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m index 3cb5613bd0..1f8c647fa6 100644 --- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m +++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m @@ -38,8 +38,6 @@ #include <grpc/byte_buffer.h> #include <grpc/support/alloc.h> -#import "GRPCRequestHeaders.h" - #import "GRPCCompletionQueue.h" #import "GRPCHost.h" #import "NSDictionary+GRPC.h" @@ -67,7 +65,7 @@ return [self initWithMetadata:nil handler:nil]; } -- (instancetype)initWithMetadata:(GRPCRequestHeaders *)metadata handler:(void (^)())handler { +- (instancetype)initWithMetadata:(id<GRPCRequestHeaders>)metadata handler:(void (^)())handler { if (self = [super init]) { _op.op = GRPC_OP_SEND_INITIAL_METADATA; _op.data.send_initial_metadata.count = metadata.count; |