From cabb0db9de5270329b272d3b33fab57f83937622 Mon Sep 17 00:00:00 2001 From: Denis Babineau Date: Tue, 28 Jul 2015 11:15:32 -0300 Subject: [PATCH] acceptAllHosts can now be called on both platform. --- src/ios/CordovaHttpPlugin.h | 1 + src/ios/CordovaHttpPlugin.m | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/ios/CordovaHttpPlugin.h b/src/ios/CordovaHttpPlugin.h index 445bc8a..fd6cd72 100644 --- a/src/ios/CordovaHttpPlugin.h +++ b/src/ios/CordovaHttpPlugin.h @@ -9,6 +9,7 @@ - (void)setHeader:(CDVInvokedUrlCommand*)command; - (void)enableSSLPinning:(CDVInvokedUrlCommand*)command; - (void)acceptAllCerts:(CDVInvokedUrlCommand*)command; +- (void)acceptAllHosts:(CDVInvokedUrlCommand*)command; - (void)post:(CDVInvokedUrlCommand*)command; - (void)get:(CDVInvokedUrlCommand*)command; - (void)uploadFile:(CDVInvokedUrlCommand*)command; diff --git a/src/ios/CordovaHttpPlugin.m b/src/ios/CordovaHttpPlugin.m index 54de660..d938047 100644 --- a/src/ios/CordovaHttpPlugin.m +++ b/src/ios/CordovaHttpPlugin.m @@ -71,6 +71,14 @@ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; } +- (void)acceptAllHosts:(CDVInvokedUrlCommand*)command { + CDVPluginResult* pluginResult = nil; + bool allow = [[command.arguments objectAtIndex:0] boolValue]; + [HttpManager sharedClient].securityPolicy.validatesDomainName = !allow; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + - (void)post:(CDVInvokedUrlCommand*)command { HttpManager *manager = [HttpManager sharedClient]; NSString *url = [command.arguments objectAtIndex:0];