Merge pull request #45 from muxi/metadata_filter

Fix test errors
reviewable/pr8842/r9
Craig Tiller 8 years ago committed by GitHub
commit 4659c32a0a
  1. 14
      src/objective-c/GRPCClient/private/GRPCWrappedCall.m
  2. 4
      src/objective-c/GRPCClient/private/NSDictionary+GRPC.m

@ -215,11 +215,15 @@
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
_handler = ^{ _handler = ^{
__strong typeof(self) strongSelf = weakSelf; __strong typeof(self) strongSelf = weakSelf;
NSError *error = [NSError grpc_errorFromStatusCode:strongSelf->_statusCode if (strongSelf) {
details:(char*)GRPC_SLICE_START_PTR(strongSelf->_details)]; char *details = grpc_slice_to_c_string(strongSelf->_details);
NSDictionary *trailers = [NSDictionary NSError *error = [NSError grpc_errorFromStatusCode:strongSelf->_statusCode
grpc_dictionaryFromMetadataArray:strongSelf->_trailers]; details:details];
handler(error, trailers); NSDictionary *trailers = [NSDictionary
grpc_dictionaryFromMetadataArray:strongSelf->_trailers];
handler(error, trailers);
gpr_free(details);
}
}; };
} }
} }

@ -88,8 +88,10 @@
+ (instancetype)grpc_dictionaryFromMetadata:(grpc_metadata *)entries count:(size_t)count { + (instancetype)grpc_dictionaryFromMetadata:(grpc_metadata *)entries count:(size_t)count {
NSMutableDictionary *metadata = [NSMutableDictionary dictionaryWithCapacity:count]; NSMutableDictionary *metadata = [NSMutableDictionary dictionaryWithCapacity:count];
for (grpc_metadata *entry = entries; entry < entries + count; entry++) { for (grpc_metadata *entry = entries; entry < entries + count; entry++) {
NSString *name = [NSString stringWithCString:(char*)GRPC_SLICE_START_PTR(entry->key) char *key = grpc_slice_to_c_string(entry->key);
NSString *name = [NSString stringWithCString:key
encoding:NSASCIIStringEncoding]; encoding:NSASCIIStringEncoding];
gpr_free(key);
if (!name || metadata[name]) { if (!name || metadata[name]) {
// Log if name is nil? // Log if name is nil?
continue; continue;

Loading…
Cancel
Save