aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2015-09-02 22:56:01 -0700
committerGravatar Jorge Canizales <jcanizales@google.com>2015-09-02 22:56:01 -0700
commitacf5e107f3678334c08cc5effdbc73c3ae3f9042 (patch)
treece1d3dc426bcfcaa753ad56f9c9972202d2bd3a5 /src/objective-c/GRPCClient/private/GRPCRequestHeaders.m
parent12da424c9ae7fe35b926bfb5761ec1a300ccbf0f (diff)
Let remove nil or non-ASCII keys (noop instead of throw).
Diffstat (limited to 'src/objective-c/GRPCClient/private/GRPCRequestHeaders.m')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCRequestHeaders.m10
1 files 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 {