mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2026-01-31 00:00:03 +08:00
Add support for sending 'raw' requests on Android
request.data can be `Uint8Array` or `ArrayBuffer`. The plugin will send it as is, without any processing.
This commit is contained in:
@@ -159,6 +159,8 @@ abstract class CordovaHttpBase implements Runnable {
|
||||
request.send(this.data.toString());
|
||||
} else if ("utf8".equals(this.serializer)) {
|
||||
request.send(((JSONObject) this.data).getString("text"));
|
||||
} else if ("raw".equals(this.serializer)) {
|
||||
request.send(Base64.decode((String)this.data, Base64.DEFAULT));
|
||||
} else if ("urlencoded".equals(this.serializer)) {
|
||||
request.form(JsonUtils.getObjectMap((JSONObject) this.data));
|
||||
} else if ("multipart".equals(this.serializer)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = function init(global, jsUtil, cookieHandler, messages, base64, errorCodes, dependencyValidator, ponyfills) {
|
||||
var validSerializers = ['urlencoded', 'json', 'utf8', 'multipart'];
|
||||
var validSerializers = ['urlencoded', 'json', 'utf8', 'raw', 'multipart'];
|
||||
var validCertModes = ['default', 'nocheck', 'pinned', 'legacy'];
|
||||
var validClientAuthModes = ['none', 'systemstore', 'buffer'];
|
||||
var validHttpMethods = ['get', 'put', 'post', 'patch', 'head', 'delete', 'upload', 'download'];
|
||||
@@ -365,6 +365,8 @@ module.exports = function init(global, jsUtil, cookieHandler, messages, base64,
|
||||
return ['Object'];
|
||||
case 'json':
|
||||
return ['Array', 'Object'];
|
||||
case 'raw':
|
||||
return ['Uint8Array', 'ArrayBuffer'];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
@@ -400,6 +402,8 @@ module.exports = function init(global, jsUtil, cookieHandler, messages, base64,
|
||||
switch (dataSerializer) {
|
||||
case 'utf8':
|
||||
return cb({ text: data });
|
||||
case 'raw':
|
||||
return cb(currentDataType === 'Uint8Array' ? data.buffer : data);
|
||||
case 'multipart':
|
||||
return processFormData(data, cb);
|
||||
default:
|
||||
|
||||
@@ -6,6 +6,8 @@ module.exports = {
|
||||
return 'Array';
|
||||
case '[object Blob]':
|
||||
return 'Blob';
|
||||
case '[object Uint8Array]':
|
||||
return 'Uint8Array';
|
||||
case '[object ArrayBuffer]':
|
||||
return 'ArrayBuffer';
|
||||
case '[object Boolean]':
|
||||
|
||||
Reference in New Issue
Block a user