diff --git a/CHANGELOG.md b/CHANGELOG.md index 1daade2..3d67ae4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.5.7 + +- Added setRequestTimeout function to set the timeout in seconds for all further requests + ## v1.5.6 - All response header keys are converted to lowercase (iOS only) diff --git a/package.json b/package.json index e945197..16d568b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-advanced-http", - "version": "1.5.6", + "version": "1.5.7", "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 61bdd16..34131a2 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.5.7"> Advanced HTTP plugin diff --git a/src/android/com/synconset/cordovahttp/CordovaHttp.java b/src/android/com/synconset/cordovahttp/CordovaHttp.java index 8ff2079..cce3aef 100644 --- a/src/android/com/synconset/cordovahttp/CordovaHttp.java +++ b/src/android/com/synconset/cordovahttp/CordovaHttp.java @@ -30,21 +30,24 @@ abstract class CordovaHttp { private JSONObject params; private String serializerName; private JSONObject headers; + private int timeoutInMilliseconds; private CallbackContext callbackContext; - public CordovaHttp(String urlString, JSONObject params, JSONObject headers, CallbackContext callbackContext) { + public CordovaHttp(String urlString, JSONObject params, JSONObject headers, int timeout, CallbackContext callbackContext) { this.urlString = urlString; this.params = params; this.serializerName = "default"; this.headers = headers; + this.timeoutInMilliseconds = timeout; this.callbackContext = callbackContext; } - public CordovaHttp(String urlString, JSONObject params, String serializerName, JSONObject headers, CallbackContext callbackContext) { + public CordovaHttp(String urlString, JSONObject params, String serializerName, JSONObject headers, int timeout, CallbackContext callbackContext) { this.urlString = urlString; this.params = params; this.serializerName = serializerName; this.headers = headers; + this.timeoutInMilliseconds = timeout; this.callbackContext = callbackContext; } @@ -90,6 +93,10 @@ abstract class CordovaHttp { return this.getStringMapFromJSONObject(this.headers); } + protected int getRequestTimeout() { + return this.timeoutInMilliseconds; + } + protected CallbackContext getCallbackContext() { return this.callbackContext; } diff --git a/src/android/com/synconset/cordovahttp/CordovaHttpDelete.java b/src/android/com/synconset/cordovahttp/CordovaHttpDelete.java index 604e6a5..20e3d2f 100644 --- a/src/android/com/synconset/cordovahttp/CordovaHttpDelete.java +++ b/src/android/com/synconset/cordovahttp/CordovaHttpDelete.java @@ -16,8 +16,8 @@ import com.github.kevinsawicki.http.HttpRequest; import com.github.kevinsawicki.http.HttpRequest.HttpRequestException; class CordovaHttpDelete extends CordovaHttp implements Runnable { - public CordovaHttpDelete(String urlString, JSONObject data, JSONObject headers, CallbackContext callbackContext) { - super(urlString, data, headers, callbackContext); + public CordovaHttpDelete(String urlString, JSONObject data, JSONObject headers, CallbackContext callbackContext, int timeout) { + super(urlString, data, headers, timeout, callbackContext); } @Override @@ -25,6 +25,7 @@ class CordovaHttpDelete extends CordovaHttp implements Runnable { try { HttpRequest request = HttpRequest.delete(this.getUrlString(), this.getParamsMap(), false); + request.readTimeout(this.getRequestTimeout()); this.setupSecurity(request); request.acceptCharset(CHARSET); request.headers(this.getHeadersMap()); diff --git a/src/android/com/synconset/cordovahttp/CordovaHttpDownload.java b/src/android/com/synconset/cordovahttp/CordovaHttpDownload.java index b5c213c..f55e825 100644 --- a/src/android/com/synconset/cordovahttp/CordovaHttpDownload.java +++ b/src/android/com/synconset/cordovahttp/CordovaHttpDownload.java @@ -22,8 +22,8 @@ import org.json.JSONObject; class CordovaHttpDownload extends CordovaHttp implements Runnable { private String filePath; - public CordovaHttpDownload(String urlString, JSONObject params, JSONObject headers, CallbackContext callbackContext, String filePath) { - super(urlString, params, headers, callbackContext); + public CordovaHttpDownload(String urlString, JSONObject params, JSONObject headers, CallbackContext callbackContext, String filePath, int timeout) { + super(urlString, params, headers, timeout, callbackContext); this.filePath = filePath; } @@ -31,6 +31,8 @@ class CordovaHttpDownload extends CordovaHttp implements Runnable { public void run() { try { HttpRequest request = HttpRequest.get(this.getUrlString(), this.getParamsMap(), true); + + request.readTimeout(this.getRequestTimeout()); this.setupSecurity(request); request.acceptCharset(CHARSET); request.headers(this.getHeadersMap()); diff --git a/src/android/com/synconset/cordovahttp/CordovaHttpGet.java b/src/android/com/synconset/cordovahttp/CordovaHttpGet.java index dc10242..176ba06 100644 --- a/src/android/com/synconset/cordovahttp/CordovaHttpGet.java +++ b/src/android/com/synconset/cordovahttp/CordovaHttpGet.java @@ -16,8 +16,8 @@ import com.github.kevinsawicki.http.HttpRequest; import com.github.kevinsawicki.http.HttpRequest.HttpRequestException; class CordovaHttpGet extends CordovaHttp implements Runnable { - public CordovaHttpGet(String urlString, JSONObject params, JSONObject headers, CallbackContext callbackContext) { - super(urlString, params, headers, callbackContext); + public CordovaHttpGet(String urlString, JSONObject params, JSONObject headers, CallbackContext callbackContext, int timeout) { + super(urlString, params, headers, timeout, callbackContext); } @Override @@ -25,6 +25,7 @@ class CordovaHttpGet extends CordovaHttp implements Runnable { try { HttpRequest request = HttpRequest.get(this.getUrlString(), this.getParamsMap(), false); + request.readTimeout(this.getRequestTimeout()); this.setupSecurity(request); request.acceptCharset(CHARSET); request.headers(this.getHeadersMap()); diff --git a/src/android/com/synconset/cordovahttp/CordovaHttpHead.java b/src/android/com/synconset/cordovahttp/CordovaHttpHead.java index bafa3b5..4763b1f 100644 --- a/src/android/com/synconset/cordovahttp/CordovaHttpHead.java +++ b/src/android/com/synconset/cordovahttp/CordovaHttpHead.java @@ -15,8 +15,8 @@ import com.github.kevinsawicki.http.HttpRequest; import com.github.kevinsawicki.http.HttpRequest.HttpRequestException; class CordovaHttpHead extends CordovaHttp implements Runnable { - public CordovaHttpHead(String urlString, JSONObject params, JSONObject headers, CallbackContext callbackContext) { - super(urlString, params, headers, callbackContext); + public CordovaHttpHead(String urlString, JSONObject params, JSONObject headers, CallbackContext callbackContext, int timeout) { + super(urlString, params, headers, timeout, callbackContext); } @Override @@ -24,6 +24,7 @@ class CordovaHttpHead extends CordovaHttp implements Runnable { try { HttpRequest request = HttpRequest.head(this.getUrlString(), this.getParamsMap(), true); + request.readTimeout(this.getRequestTimeout()); this.setupSecurity(request); request.acceptCharset(CHARSET); request.headers(this.getHeadersMap()); diff --git a/src/android/com/synconset/cordovahttp/CordovaHttpPlugin.java b/src/android/com/synconset/cordovahttp/CordovaHttpPlugin.java index 8e2c99a..e74908e 100644 --- a/src/android/com/synconset/cordovahttp/CordovaHttpPlugin.java +++ b/src/android/com/synconset/cordovahttp/CordovaHttpPlugin.java @@ -39,14 +39,16 @@ public class CordovaHttpPlugin extends CordovaPlugin { JSONObject params = args.getJSONObject(1); String serializerName = args.getString(2); JSONObject headers = args.getJSONObject(3); - CordovaHttpPost post = new CordovaHttpPost(urlString, params, serializerName, headers, callbackContext); + int timeoutInMilliseconds = args.getInt(4) * 1000; + CordovaHttpPost post = new CordovaHttpPost(urlString, params, serializerName, headers, callbackContext, timeoutInMilliseconds); cordova.getThreadPool().execute(post); } else if (action.equals("get")) { String urlString = args.getString(0); JSONObject params = args.getJSONObject(1); JSONObject headers = args.getJSONObject(2); - CordovaHttpGet get = new CordovaHttpGet(urlString, params, headers, callbackContext); + int timeoutInMilliseconds = args.getInt(3) * 1000; + CordovaHttpGet get = new CordovaHttpGet(urlString, params, headers, callbackContext, timeoutInMilliseconds); cordova.getThreadPool().execute(get); } else if (action.equals("put")) { @@ -54,21 +56,24 @@ public class CordovaHttpPlugin extends CordovaPlugin { JSONObject params = args.getJSONObject(1); String serializerName = args.getString(2); JSONObject headers = args.getJSONObject(3); - CordovaHttpPut put = new CordovaHttpPut(urlString, params, serializerName, headers, callbackContext); + int timeoutInMilliseconds = args.getInt(4) * 1000; + CordovaHttpPut put = new CordovaHttpPut(urlString, params, serializerName, headers, callbackContext, timeoutInMilliseconds); cordova.getThreadPool().execute(put); } else if (action.equals("delete")) { String urlString = args.getString(0); JSONObject params = args.getJSONObject(1); JSONObject headers = args.getJSONObject(2); - CordovaHttpDelete delete = new CordovaHttpDelete(urlString, params, headers, callbackContext); + int timeoutInMilliseconds = args.getInt(3) * 1000; + CordovaHttpDelete delete = new CordovaHttpDelete(urlString, params, headers, callbackContext, timeoutInMilliseconds); cordova.getThreadPool().execute(delete); } else if (action.equals("head")) { String urlString = args.getString(0); JSONObject params = args.getJSONObject(1); JSONObject headers = args.getJSONObject(2); - CordovaHttpHead head = new CordovaHttpHead(urlString, params, headers, callbackContext); + int timeoutInMilliseconds = args.getInt(3) * 1000; + CordovaHttpHead head = new CordovaHttpHead(urlString, params, headers, callbackContext, timeoutInMilliseconds); cordova.getThreadPool().execute(head); } else if (action.equals("enableSSLPinning")) { @@ -96,7 +101,8 @@ public class CordovaHttpPlugin extends CordovaPlugin { JSONObject headers = args.getJSONObject(2); String filePath = args.getString(3); String name = args.getString(4); - CordovaHttpUpload upload = new CordovaHttpUpload(urlString, params, headers, callbackContext, filePath, name); + int timeoutInMilliseconds = args.getInt(5) * 1000; + CordovaHttpUpload upload = new CordovaHttpUpload(urlString, params, headers, callbackContext, filePath, name, timeoutInMilliseconds); cordova.getThreadPool().execute(upload); } else if (action.equals("downloadFile")) { @@ -104,7 +110,8 @@ public class CordovaHttpPlugin extends CordovaPlugin { JSONObject params = args.getJSONObject(1); JSONObject headers = args.getJSONObject(2); String filePath = args.getString(3); - CordovaHttpDownload download = new CordovaHttpDownload(urlString, params, headers, callbackContext, filePath); + int timeoutInMilliseconds = args.getInt(4) * 1000; + CordovaHttpDownload download = new CordovaHttpDownload(urlString, params, headers, callbackContext, filePath, timeoutInMilliseconds); cordova.getThreadPool().execute(download); } else { diff --git a/src/android/com/synconset/cordovahttp/CordovaHttpPost.java b/src/android/com/synconset/cordovahttp/CordovaHttpPost.java index af9c25a..5e741f6 100644 --- a/src/android/com/synconset/cordovahttp/CordovaHttpPost.java +++ b/src/android/com/synconset/cordovahttp/CordovaHttpPost.java @@ -15,8 +15,8 @@ import com.github.kevinsawicki.http.HttpRequest; import com.github.kevinsawicki.http.HttpRequest.HttpRequestException; class CordovaHttpPost extends CordovaHttp implements Runnable { - public CordovaHttpPost(String urlString, JSONObject params, String serializerName, JSONObject headers, CallbackContext callbackContext) { - super(urlString, params, serializerName, headers, callbackContext); + public CordovaHttpPost(String urlString, JSONObject params, String serializerName, JSONObject headers, CallbackContext callbackContext, int timeout) { + super(urlString, params, serializerName, headers, timeout, callbackContext); } @Override @@ -24,6 +24,7 @@ class CordovaHttpPost extends CordovaHttp implements Runnable { try { HttpRequest request = HttpRequest.post(this.getUrlString()); + request.readTimeout(this.getRequestTimeout()); this.setupSecurity(request); request.acceptCharset(CHARSET); request.headers(this.getHeadersMap()); @@ -51,7 +52,7 @@ class CordovaHttpPost extends CordovaHttp implements Runnable { } } catch (JSONException e) { this.respondWithError("There was an error generating the response"); - } catch (HttpRequestException e) { + } catch (HttpRequestException e) { if (e.getCause() instanceof UnknownHostException) { this.respondWithError(0, "The host could not be resolved"); } else if (e.getCause() instanceof SSLHandshakeException) { diff --git a/src/android/com/synconset/cordovahttp/CordovaHttpPut.java b/src/android/com/synconset/cordovahttp/CordovaHttpPut.java index ac533d2..fb1cc4f 100644 --- a/src/android/com/synconset/cordovahttp/CordovaHttpPut.java +++ b/src/android/com/synconset/cordovahttp/CordovaHttpPut.java @@ -15,8 +15,8 @@ import com.github.kevinsawicki.http.HttpRequest; import com.github.kevinsawicki.http.HttpRequest.HttpRequestException; class CordovaHttpPut extends CordovaHttp implements Runnable { - public CordovaHttpPut(String urlString, JSONObject data, String serializerName, JSONObject headers, CallbackContext callbackContext) { - super(urlString, data, serializerName, headers, callbackContext); + public CordovaHttpPut(String urlString, JSONObject data, String serializerName, JSONObject headers, CallbackContext callbackContext, int timeout) { + super(urlString, data, serializerName, headers, timeout, callbackContext); } @Override @@ -24,6 +24,7 @@ class CordovaHttpPut extends CordovaHttp implements Runnable { try { HttpRequest request = HttpRequest.put(this.getUrlString()); + request.readTimeout(this.getRequestTimeout()); this.setupSecurity(request); request.acceptCharset(CHARSET); request.headers(this.getHeadersMap()); diff --git a/src/android/com/synconset/cordovahttp/CordovaHttpUpload.java b/src/android/com/synconset/cordovahttp/CordovaHttpUpload.java index 1ad144e..46b75bd 100644 --- a/src/android/com/synconset/cordovahttp/CordovaHttpUpload.java +++ b/src/android/com/synconset/cordovahttp/CordovaHttpUpload.java @@ -29,8 +29,8 @@ class CordovaHttpUpload extends CordovaHttp implements Runnable { private String filePath; private String name; - public CordovaHttpUpload(String urlString, JSONObject params, JSONObject headers, CallbackContext callbackContext, String filePath, String name) { - super(urlString, params, headers, callbackContext); + public CordovaHttpUpload(String urlString, JSONObject params, JSONObject headers, CallbackContext callbackContext, String filePath, String name, int timeout) { + super(urlString, params, headers, timeout, callbackContext); this.filePath = filePath; this.name = name; } @@ -40,6 +40,7 @@ class CordovaHttpUpload extends CordovaHttp implements Runnable { try { HttpRequest request = HttpRequest.post(this.getUrlString()); + request.readTimeout(this.getRequestTimeout()); this.setupSecurity(request); request.acceptCharset(CHARSET); request.headers(this.getHeadersMap()); diff --git a/src/ios/CordovaHttpPlugin.m b/src/ios/CordovaHttpPlugin.m index 17d7fa5..47fb8a3 100644 --- a/src/ios/CordovaHttpPlugin.m +++ b/src/ios/CordovaHttpPlugin.m @@ -8,6 +8,7 @@ - (void)setRequestHeaders:(NSDictionary*)headers forManager:(AFHTTPSessionManager*)manager; - (void)setResults:(NSMutableDictionary*)dictionary withTask:(NSURLSessionTask*)task; - (NSMutableDictionary*)copyHeaderFields:(NSDictionary*)headerFields; +- (void)setTimeout:(NSTimeInterval)timeout forManager:(AFHTTPSessionManager*)manager; @end @@ -54,6 +55,10 @@ return headerFieldsCopy; } +- (void)setTimeout:(NSTimeInterval)timeout forManager:(AFHTTPSessionManager*)manager { + [manager.requestSerializer setTimeoutInterval:timeout]; +} + - (void)enableSSLPinning:(CDVInvokedUrlCommand*)command { bool enable = [[command.arguments objectAtIndex:0] boolValue]; if (enable) { @@ -89,12 +94,16 @@ - (void)post:(CDVInvokedUrlCommand*)command { AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.securityPolicy = securityPolicy; + NSString *url = [command.arguments objectAtIndex:0]; NSDictionary *parameters = [command.arguments objectAtIndex:1]; NSString *serializerName = [command.arguments objectAtIndex:2]; NSDictionary *headers = [command.arguments objectAtIndex:3]; + NSTimeInterval timeoutInSeconds = [[command.arguments objectAtIndex:4] doubleValue]; + [self setRequestSerializer: serializerName forManager: manager]; [self setRequestHeaders: headers forManager: manager]; + [self setTimeout:timeoutInSeconds forManager:manager]; CordovaHttpPlugin* __weak weakSelf = self; manager.responseSerializer = [TextResponseSerializer serializer]; @@ -117,11 +126,16 @@ - (void)get:(CDVInvokedUrlCommand*)command { AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.securityPolicy = securityPolicy; + NSString *url = [command.arguments objectAtIndex:0]; NSDictionary *parameters = [command.arguments objectAtIndex:1]; NSDictionary *headers = [command.arguments objectAtIndex:2]; + NSTimeInterval timeoutInSeconds = [[command.arguments objectAtIndex:3] doubleValue]; + + [self setRequestSerializer: @"default" forManager: manager]; [self setRequestHeaders: headers forManager: manager]; + [self setTimeout:timeoutInSeconds forManager:manager]; CordovaHttpPlugin* __weak weakSelf = self; @@ -145,12 +159,16 @@ - (void)put:(CDVInvokedUrlCommand*)command { AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.securityPolicy = securityPolicy; + NSString *url = [command.arguments objectAtIndex:0]; NSDictionary *parameters = [command.arguments objectAtIndex:1]; NSString *serializerName = [command.arguments objectAtIndex:2]; NSDictionary *headers = [command.arguments objectAtIndex:3]; + NSTimeInterval timeoutInSeconds = [[command.arguments objectAtIndex:4] doubleValue]; + [self setRequestSerializer: serializerName forManager: manager]; [self setRequestHeaders: headers forManager: manager]; + [self setTimeout:timeoutInSeconds forManager:manager]; CordovaHttpPlugin* __weak weakSelf = self; manager.responseSerializer = [TextResponseSerializer serializer]; @@ -173,11 +191,15 @@ - (void)delete:(CDVInvokedUrlCommand*)command { AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.securityPolicy = securityPolicy; + NSString *url = [command.arguments objectAtIndex:0]; NSDictionary *parameters = [command.arguments objectAtIndex:1]; NSDictionary *headers = [command.arguments objectAtIndex:2]; + NSTimeInterval timeoutInSeconds = [[command.arguments objectAtIndex:3] doubleValue]; + [self setRequestSerializer: @"default" forManager: manager]; [self setRequestHeaders: headers forManager: manager]; + [self setTimeout:timeoutInSeconds forManager:manager]; CordovaHttpPlugin* __weak weakSelf = self; @@ -204,7 +226,10 @@ NSString *url = [command.arguments objectAtIndex:0]; NSDictionary *parameters = [command.arguments objectAtIndex:1]; NSDictionary *headers = [command.arguments objectAtIndex:2]; + NSTimeInterval timeoutInSeconds = [[command.arguments objectAtIndex:3] doubleValue]; + [self setRequestHeaders: headers forManager: manager]; + [self setTimeout:timeoutInSeconds forManager:manager]; CordovaHttpPlugin* __weak weakSelf = self; @@ -228,15 +253,18 @@ - (void)uploadFile:(CDVInvokedUrlCommand*)command { AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.securityPolicy = securityPolicy; + NSString *url = [command.arguments objectAtIndex:0]; NSDictionary *parameters = [command.arguments objectAtIndex:1]; NSDictionary *headers = [command.arguments objectAtIndex:2]; NSString *filePath = [command.arguments objectAtIndex: 3]; NSString *name = [command.arguments objectAtIndex: 4]; + NSTimeInterval timeoutInSeconds = [[command.arguments objectAtIndex:5] doubleValue]; NSURL *fileURL = [NSURL URLWithString: filePath]; [self setRequestHeaders: headers forManager: manager]; + [self setTimeout:timeoutInSeconds forManager:manager]; CordovaHttpPlugin* __weak weakSelf = self; manager.responseSerializer = [TextResponseSerializer serializer]; @@ -270,12 +298,16 @@ - (void)downloadFile:(CDVInvokedUrlCommand*)command { AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.securityPolicy = securityPolicy; + NSString *url = [command.arguments objectAtIndex:0]; NSDictionary *parameters = [command.arguments objectAtIndex:1]; NSDictionary *headers = [command.arguments objectAtIndex:2]; NSString *filePath = [command.arguments objectAtIndex: 3]; + NSTimeInterval timeoutInSeconds = [[command.arguments objectAtIndex:4] doubleValue]; + [self setRequestHeaders: headers forManager: manager]; + [self setTimeout:timeoutInSeconds forManager:manager]; if ([filePath hasPrefix:@"file://"]) { filePath = [filePath substringFromIndex:7]; diff --git a/www/advanced-http.js b/www/advanced-http.js index 30ccddb..36b62d3 100644 --- a/www/advanced-http.js +++ b/www/advanced-http.js @@ -128,6 +128,7 @@ var http = { headers: {}, dataSerializer: 'urlencoded', sslPinning: false, + timeoutInSeconds: 60.0, getBasicAuthHeader: function (username, password) { return {'Authorization': 'Basic ' + b64EncodeUnicode(username + ':' + password)}; }, @@ -146,6 +147,9 @@ var http = { removeCookies: function (url, callback) { cookieHandler.removeCookies(url, callback); }, + setRequestTimeout: function(timeout) { + this.timeoutInSeconds = timeout; + }, enableSSLPinning: function (enable, success, failure) { return exec(success, failure, 'CordovaHttpPlugin', 'enableSSLPinning', [enable]); }, @@ -166,7 +170,7 @@ var http = { var onSuccess = injectCookieHandler(url, success); var onFail = injectCookieHandler(url, failure); - return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'post', [url, data, this.dataSerializer, headers]); + return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'post', [url, data, this.dataSerializer, headers, this.timeoutInSeconds]); }, get: function (url, params, headers, success, failure) { handleMissingCallbacks(success, failure); @@ -179,7 +183,7 @@ var http = { var onSuccess = injectCookieHandler(url, success); var onFail = injectCookieHandler(url, failure); - return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'get', [url, params, headers]); + return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'get', [url, params, headers, this.timeoutInSeconds]); }, put: function (url, data, headers, success, failure) { handleMissingCallbacks(success, failure); @@ -192,7 +196,7 @@ var http = { var onSuccess = injectCookieHandler(url, success); var onFail = injectCookieHandler(url, failure); - return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'put', [url, data, this.dataSerializer, headers]); + return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'put', [url, data, this.dataSerializer, headers, this.timeoutInSeconds]); }, delete: function (url, params, headers, success, failure) { handleMissingCallbacks(success, failure); @@ -205,7 +209,7 @@ var http = { var onSuccess = injectCookieHandler(url, success); var onFail = injectCookieHandler(url, failure); - return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'delete', [url, params, headers]); + return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'delete', [url, params, headers, this.timeoutInSeconds]); }, head: function (url, params, headers, success, failure) { handleMissingCallbacks(success, failure); @@ -218,7 +222,7 @@ var http = { var onSuccess = injectCookieHandler(url, success); var onFail = injectCookieHandler(url, failure); - return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'head', [url, params, headers]); + return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'head', [url, params, headers, this.timeoutInSeconds]); }, uploadFile: function (url, params, headers, filePath, name, success, failure) { handleMissingCallbacks(success, failure); @@ -231,7 +235,7 @@ var http = { var onSuccess = injectCookieHandler(url, success); var onFail = injectCookieHandler(url, failure); - return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'uploadFile', [url, params, headers, filePath, name]); + return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'uploadFile', [url, params, headers, filePath, name, this.timeoutInSeconds]); }, downloadFile: function (url, params, headers, filePath, success, failure) { handleMissingCallbacks(success, failure); @@ -244,7 +248,7 @@ var http = { var onSuccess = injectCookieHandler(url, injectFileEntryHandler(success)); var onFail = injectCookieHandler(url, failure); - return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'downloadFile', [url, params, headers, filePath]); + return exec(onSuccess, onFail, 'CordovaHttpPlugin', 'downloadFile', [url, params, headers, filePath, this.timeoutInSeconds]); } }; diff --git a/www/angular-integration.js b/www/angular-integration.js index ec525c9..eb8be2e 100644 --- a/www/angular-integration.js +++ b/www/angular-integration.js @@ -50,6 +50,9 @@ function registerService(http) { removeCookies: function (url) { return http.removeCookies(url); }, + setRequestTimeout: function (timeout) { + return http.setRequestTimeout(timeout); + }, enableSSLPinning: function (enable) { return makePromise(http.enableSSLPinning, [enable]); },