Merge branch 'setTimeout' of https://github.com/YouYue123/cordova-plugin-advanced-http into YouYue123-setTimeout

# Conflicts:
#	README.md
#	src/android/com/silkimen/cordovahttp/CordovaHttpBase.java
#	src/android/com/silkimen/cordovahttp/CordovaHttpDownload.java
#	src/android/com/silkimen/cordovahttp/CordovaHttpOperation.java
#	src/ios/CordovaHttpPlugin.m
#	www/public-interface.js
This commit is contained in:
Sefa Ilkimen
2021-08-20 04:37:49 +02:00
10 changed files with 113 additions and 46 deletions
+2
View File
@@ -3,6 +3,8 @@ var globalConfigs = {
serializer: 'urlencoded',
followRedirect: true,
timeout: 60.0,
connectTimeout: 60.0,
readTimeout: 60.0
};
module.exports = globalConfigs;
+3 -1
View File
@@ -505,7 +505,9 @@ module.exports = function init(global, jsUtil, cookieHandler, messages, base64,
params: checkParamsObject(options.params || {}),
responseType: checkResponseType(options.responseType || validResponseTypes[0]),
serializer: checkSerializer(options.serializer || globals.serializer),
timeout: checkTimeoutValue(options.timeout || globals.timeout),
connectTimeout: checkTimeoutValue(options.connectTimeout || globals.connectTimeout),
readTimeout: checkTimeoutValue(options.readTimeout || globals.readTimeout),
timeout: checkTimeoutValue(options.timeout || globals.timeout)
};
}
};
+28 -7
View File
@@ -14,6 +14,12 @@ module.exports = function init(exec, cookieHandler, urlUtil, helpers, globalConf
setRequestTimeout: setRequestTimeout,
getFollowRedirect: getFollowRedirect,
setFollowRedirect: setFollowRedirect,
// @Android Only
getConnectTimeout: getConnectTimeout,
// @Android Only
setConnectTimeout: setConnectTimeout,
getReadTimeout: getReadTimeout,
setReadTimeout: setReadTimeout,
setServerTrustMode: setServerTrustMode,
setClientAuthMode: setClientAuthMode,
sendRequest: sendRequest,
@@ -97,6 +103,24 @@ module.exports = function init(exec, cookieHandler, urlUtil, helpers, globalConf
function setRequestTimeout(timeout) {
globalConfigs.timeout = helpers.checkTimeoutValue(timeout);
globalConfigs.connectTimeout = helpers.checkTimeoutValue(timeout);
globalConfigs.readTimeout = helpers.checkTimeoutValue(timeout);
}
function getConnectTimeout() {
return globalConfigs.connectTimeout;
}
function setConnectTimeout(timeout) {
globalConfigs.connectTimeout = helpers.checkTimeoutValue(timeout);
}
function getReadTimeout() {
return globalConfigs.readTimeout;
}
function setReadTimeout(timeout) {
globalConfigs.readTimeout = helpers.checkTimeoutValue(timeout);
}
function getFollowRedirect() {
@@ -151,21 +175,18 @@ module.exports = function init(exec, cookieHandler, urlUtil, helpers, globalConf
case 'put':
case 'patch':
helpers.processData(options.data, options.serializer, function (data) {
exec(onSuccess, onFail, 'CordovaHttpPlugin', options.method, [url, data, options.serializer, headers, options.timeout, options.followRedirect, options.responseType, reqId]);
exec(onSuccess, onFail, 'CordovaHttpPlugin', options.method, [url, data, options.serializer, headers, options.connectTimeout, options.readTimeout, options.followRedirect, options.responseType, reqId]);
});
break;
case 'upload':
var fileOptions = helpers.checkUploadFileOptions(options.filePath, options.name);
exec(onSuccess, onFail, 'CordovaHttpPlugin', 'uploadFiles', [url, headers, fileOptions.filePaths, fileOptions.names, options.timeout, options.followRedirect, options.responseType, reqId]);
break;
exec(onSuccess, onFail, 'CordovaHttpPlugin', 'uploadFiles', [url, headers, fileOptions.filePaths, fileOptions.names, options.connectTimeout, options.readTimeout, options.followRedirect, options.responseType, reqId]);
case 'download':
var filePath = helpers.checkDownloadFilePath(options.filePath);
var onDownloadSuccess = helpers.injectCookieHandler(url, helpers.injectFileEntryHandler(success));
exec(onDownloadSuccess, onFail, 'CordovaHttpPlugin', 'downloadFile', [url, headers, filePath, options.timeout, options.followRedirect, reqId]);
break;
exec(onDownloadSuccess, onFail, 'CordovaHttpPlugin', 'downloadFile', [url, headers, filePath, options.connectTimeout, options.readTimeout, options.followRedirect, reqId]);
default:
exec(onSuccess, onFail, 'CordovaHttpPlugin', options.method, [url, headers, options.timeout, options.followRedirect, options.responseType, reqId]);
break;
exec(onSuccess, onFail, 'CordovaHttpPlugin', options.method, [url, headers, options.connectTimeout, options.readTimeout, options.followRedirect, options.responseType, reqId]);
}
return reqId;