mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2026-04-24 00:00:03 +08:00
WIP: major progress for #101
- feat(www): implement preprocessor for FormData instances - feat(www): implement API checks for multipart requests - feat(android): implement multipart requests - chore(specs): implement www specs for new prprocessor
This commit is contained in:
@@ -1,22 +1,43 @@
|
||||
module.exports = function init(FormData, console, messages) {
|
||||
module.exports = function init(global, console, messages) {
|
||||
var interface = {
|
||||
checkBlobApi: checkBlobApi,
|
||||
checkFileReaderApi: checkFileReaderApi,
|
||||
checkFormDataApi: checkFormDataApi,
|
||||
checkTextEncoderApi: checkTextEncoderApi,
|
||||
logWarnings: logWarnings,
|
||||
};
|
||||
|
||||
return interface;
|
||||
|
||||
function logWarnings() {
|
||||
if (!FormData) {
|
||||
if (!global.FormData) {
|
||||
console.warn(messages.MISSING_FORMDATA_API);
|
||||
} else if (!FormData.prototype || !FormData.prototype.entries) {
|
||||
} else if (!global.FormData.prototype || !global.FormData.prototype.entries) {
|
||||
console.warn(messages.MISSING_FORMDATA_ENTRIES_API);
|
||||
}
|
||||
}
|
||||
|
||||
function checkBlobApi() {
|
||||
if (!global.Blob || !global.Blob.prototype) {
|
||||
throw new Error(messages.MISSING_BLOB_API);
|
||||
}
|
||||
}
|
||||
|
||||
function checkFileReaderApi() {
|
||||
if (!global.FileReader || !global.FileReader.prototype) {
|
||||
throw new Error(messages.MISSING_FILE_READER_API);
|
||||
}
|
||||
}
|
||||
|
||||
function checkFormDataApi() {
|
||||
if (!FormData || !FormData.prototype || !FormData.prototype.entries) {
|
||||
if (!global.FormData || !global.FormData.prototype || !global.FormData.prototype.entries) {
|
||||
throw new Error(messages.MISSING_FORMDATA_ENTRIES_API);
|
||||
}
|
||||
}
|
||||
|
||||
function checkTextEncoderApi() {
|
||||
if (!global.TextEncoder || !global.TextEncoder.prototype) {
|
||||
throw new Error(messages.MISSING_TEXT_ENCODER_API);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user