Skip to content
Snippets Groups Projects
Commit 4659c32a authored by Craig Tiller's avatar Craig Tiller Committed by GitHub
Browse files

Merge pull request #45 from muxi/metadata_filter

Fix test errors
parents a36bdc16 d3c25948
No related branches found
No related tags found
No related merge requests found
......@@ -215,11 +215,15 @@
__weak typeof(self) weakSelf = self;
_handler = ^{
__strong typeof(self) strongSelf = weakSelf;
NSError *error = [NSError grpc_errorFromStatusCode:strongSelf->_statusCode
details:(char*)GRPC_SLICE_START_PTR(strongSelf->_details)];
NSDictionary *trailers = [NSDictionary
grpc_dictionaryFromMetadataArray:strongSelf->_trailers];
handler(error, trailers);
if (strongSelf) {
char *details = grpc_slice_to_c_string(strongSelf->_details);
NSError *error = [NSError grpc_errorFromStatusCode:strongSelf->_statusCode
details:details];
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 {
NSMutableDictionary *metadata = [NSMutableDictionary dictionaryWithCapacity:count];
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];
gpr_free(key);
if (!name || metadata[name]) {
// Log if name is nil?
continue;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment