From acf5e107f3678334c08cc5effdbc73c3ae3f9042 Mon Sep 17 00:00:00 2001 From: Jorge Canizales <jcanizales@google.com> Date: Wed, 2 Sep 2015 22:56:01 -0700 Subject: [PATCH] Let remove nil or non-ASCII keys (noop instead of throw). --- .../GRPCClient/private/GRPCRequestHeaders.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m index d0d8de89a1..50b04a6a87 100644 --- a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m +++ b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m @@ -38,8 +38,8 @@ #import "GRPCCall.h" #import "NSDictionary+GRPC.h" -// Used by the setters. -static NSString* NormalizeKey(NSString* key) { +// Used by the setter. +static void CheckKeyIsValid(NSString* key) { if (!key) { [NSException raise:NSInvalidArgumentException format:@"Key cannot be nil"]; } @@ -47,7 +47,6 @@ static NSString* NormalizeKey(NSString* key) { [NSException raise:NSInvalidArgumentException format:@"Key %@ contains non-ASCII characters", key]; } - return key.lowercaseString; } // Precondition: key isn't nil. @@ -93,14 +92,15 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) { - (void)setObject:(id)obj forKeyedSubscript:(NSString *)key { [self checkCallIsNotStarted]; - key = NormalizeKey(key); + CheckKeyIsValid(key); + key = key.lowercaseString; CheckKeyValuePairIsValid(key, obj); _proxy[key] = obj; } - (void)removeObjectForKey:(NSString *)key { [self checkCallIsNotStarted]; - [_proxy removeObjectForKey:NormalizeKey(key)]; + [_proxy removeObjectForKey:key.lowercaseString]; } - (void)removeAllObjects { -- GitLab