function request(url, method = 'GET', data = null, allow_redirect = false, RequestProperty = {}) {
var javaURL = plus.android.newObject('java.net.URL', url);
var connection = plus.android.invoke(javaURL, 'openConnection');
plus.android.invoke(connection, 'setRequestMethod', method.toLocaleUpperCase());
plus.android.invoke(connection, 'setInstanceFollowRedirects', allow_redirect);
plus.android.invoke(connection, 'setConnectTimeout', 0);
plus.android.invoke(connection, 'setReadTimeout', 0);
plus.android.invoke(connection, 'setRequestProperty', 'User-Agent',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36'
);
for (var kk in RequestProperty) {
plus.android.invoke(connection, 'setRequestProperty', kk, RequestProperty[kk]);
}
if (method.toLocaleUpperCase() == 'POST') {
var param_str = '';
if (data && typeof data == 'object') {
var param_list = [];
for (var fk in data) {
param_list.push(fk + '=' + encodeURIComponent(data[fk]));
}
param_str = param_list.join('&');
} else if (data && typeof data == 'string') {
param_str = data;
}
plus.android.invoke(connection, 'setRequestProperty', 'Content-Type', 'application/x-www-form-urlencoded');
plus.android.invoke(connection, 'setDoOutput', true);
plus.android.invoke(connection, 'setDoInput', true);
var outstream = plus.android.invoke(connection, 'getOutputStream');
var OutputStreamWriter = plus.android.importClass('java.io.OutputStreamWriter');
var outwriter = new OutputStreamWriter(outstream);
outwriter.write(param_str);
outwriter.flush();
outwriter.close();
}
var reader = plus.android.newObject('java.io.BufferedReader', plus.android.newObject('java.io.InputStreamReader',
plus.android.invoke(connection, 'getInputStream')))
var status_code = plus.android.invoke(connection, 'getResponseCode');
var response = '';
var line;
while ((line = plus.android.invoke(reader, 'readLine')) != null) {
response += line;
}
return {
'data': response || '',
'status_code': status_code,
'info': connection,
};
}