Compare commits

...
3 Commits
Author SHA1 Message Date
Jochen Becker 14eef1ca66 - convert response header keys to lowercase (iOS only)
- updated change log
- incremented version for release
2017-05-31 08:50:13 +02:00
Jochen Becker cf5a684d51 - added a function to remove all cookies for a URL
- updated change log
- incremented version for release
2017-05-23 10:26:51 +02:00
Jochen Becker c153378b4b - fixed an error if the response has no "headers" field
- updated change log
- incremented version for release
2017-03-03 11:11:04 +01:00
7 changed files with 49 additions and 5 deletions
+12
View File
@@ -1,5 +1,17 @@
# 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
## v1.5.4
- fixed an error if the response has no "headers" field
## v1.5.3
- handles cookies correctly on non-success response from server
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-advanced-http",
"version": "1.5.3",
"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",
+1 -1
View File
@@ -2,7 +2,7 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-advanced-http"
version="1.5.3">
version="1.5.6">
<name>Advanced HTTP plugin</name>
+14 -1
View File
@@ -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) {
+4 -1
View File
@@ -73,7 +73,7 @@ function checkSerializer(serializer) {
}
function resolveCookieString(headers) {
var keys = Object.keys(headers);
var keys = Object.keys(headers || {});
for (var i = 0; i < keys.length; ++i) {
if (keys[i].match(/^set-cookie$/i)) {
@@ -143,6 +143,9 @@ var http = {
clearCookies: function () {
return cookieHandler.clearCookies();
},
removeCookies: function (url, callback) {
cookieHandler.removeCookies(url, callback);
},
enableSSLPinning: function (enable, success, failure) {
return exec(success, failure, 'CordovaHttpPlugin', 'enableSSLPinning', [enable]);
},
+3
View File
@@ -47,6 +47,9 @@ function registerService(http) {
clearCookies: function () {
return http.clearCookies();
},
removeCookies: function (url) {
return http.removeCookies(url);
},
enableSSLPinning: function (enable) {
return makePromise(http.enableSSLPinning, [enable]);
},
+14 -1
View File
@@ -11,7 +11,8 @@ var cookieJar = new ToughCookie.CookieJar(store);
module.exports = {
setCookieFromString: setCookieFromString,
getCookieString: getCookieString,
clearCookies: clearCookies
clearCookies: clearCookies,
removeCookies: removeCookies
}
function splitCookieString(cookieStr) {
@@ -51,3 +52,15 @@ function getCookieString(url) {
function clearCookies() {
window.localStorage.removeItem(storeKey);
}
function removeCookies(url, cb) {
cookieJar.getCookies(url, function(error, cookies) {
if (!cookies || cookies.length === 0) {
return cb(null, []);
}
var domain = cookies[0].domain;
cookieJar.store.removeCookies(domain, null, cb);
});
}