diff --git a/CHANGELOG.md b/CHANGELOG.md index e534780..1daade2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.5.6 + +- All response header keys are converted to lowercase (iOS only) + ## v1.5.5 - added a function to remove all cookies for a URL diff --git a/package.json b/package.json index 251eeb2..e945197 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-advanced-http", - "version": "1.5.5", + "version": "1.5.6", "description": "Cordova / Phonegap plugin for communicating with HTTP servers using SSL pinning", "scripts": { "build": "cp node_modules/umd-tough-cookie/lib/umd-tough-cookie.js www/umd-tough-cookie.js", diff --git a/plugin.xml b/plugin.xml index c36db0d..61bdd16 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.5.6"> Advanced HTTP plugin diff --git a/src/ios/CordovaHttpPlugin.m b/src/ios/CordovaHttpPlugin.m index 460afd0..17d7fa5 100644 --- a/src/ios/CordovaHttpPlugin.m +++ b/src/ios/CordovaHttpPlugin.m @@ -7,6 +7,7 @@ - (void)setRequestHeaders:(NSDictionary*)headers forManager:(AFHTTPSessionManager*)manager; - (void)setResults:(NSMutableDictionary*)dictionary withTask:(NSURLSessionTask*)task; +- (NSMutableDictionary*)copyHeaderFields:(NSDictionary*)headerFields; @end @@ -37,10 +38,22 @@ if (task.response != nil) { NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response; [dictionary setObject:[NSNumber numberWithInt:response.statusCode] forKey:@"status"]; - [dictionary setObject:response.allHeaderFields forKey:@"headers"]; + [dictionary setObject:[self copyHeaderFields:response.allHeaderFields] forKey:@"headers"]; } } +- (NSMutableDictionary*)copyHeaderFields:(NSDictionary *)headerFields { + NSMutableDictionary *headerFieldsCopy = [[NSMutableDictionary alloc] initWithCapacity:headerFields.count]; + NSString *headerKeyCopy; + + for (NSString *headerKey in headerFields.allKeys) { + headerKeyCopy = [[headerKey mutableCopy] lowercaseString]; + [headerFieldsCopy setValue:[headerFields objectForKey:headerKey] forKey:headerKeyCopy]; + } + + return headerFieldsCopy; +} + - (void)enableSSLPinning:(CDVInvokedUrlCommand*)command { bool enable = [[command.arguments objectAtIndex:0] boolValue]; if (enable) {