cordovaHTTP ================== Cordova / Phonegap plugin for communicating with HTTP servers. Supports iOS and Android. ## Advantages over Javascript requests - Background threading - all requests are done in a background thread. - SSL Pinning - read more at [LumberBlog](http://blog.lumberlabs.com/2012/04/why-app-developers-should-care-about.html). ## Usage ### AngularJS This plugin creates a cordovaHTTP service inside of a cordovaHTTP module. You must load the module when you create your app's module. var app = angular.module('myApp', ['ngRoute', 'ngAnimate', 'cordovaHTTP']); You can then inject the cordovaHTTP service into your controllers. The functions can then be used identically to the examples shown below except that instead of accepting success and failure callback functions, each function returns a promise. For more information on promises in AngularJS read the [AngularJS docs](http://docs.angularjs.org/api/ng/service/$q). For more info on promises in general check out this article on [html5rocks](http://www.html5rocks.com/en/tutorials/es6/promises/). ### Not AngularJS This plugin registers a `cordovaHTTP` global on window ## Functions All available functions are documented below. Every function takes a success and error callback function as the last 2 arguments. ### useBasicAuth This sets up all future requests to use Basic HTTP authentication with the given username and password. cordovaHttp.useBasicAuth("user", "password", function() { console.log('success!'); }, function() { console.log('error :('); }); ### setHeader Set a header for all future requests. Takes a header and a value. cordovaHttp.setHeader("Header", "Value", function() { console.log('success!'); }, function() { console.log('error :('); }); ### enableSSLPinning Enable or disable SSL pinning. To use SSL pinning you must include at least one .cer SSL certificate in your app project. For ios include your certificate in the root level of your bundle (just add the .cer file to your project/target at the root level). For android include your certificate in your project's platforms/android/assets folder. In both cases all .cer files found will be loaded automatically. If you only have a .pem certificate see this [stackoverflow answer](http://stackoverflow.com/a/16583429/3182729). You want to convert it to a DER encoded certificate with a .cer extension. cordovaHttp.enableSSLPinning(true, function() { console.log('success!'); }, function() { console.log('error :('); }); ### acceptAllCerts Accept all SSL certificates. Or disable accepting all certificates. cordovaHttp.acceptAllCerts(true, function() { console.log('success!'); }, function() { console.log('error :('); }); ### post