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:
Sefa Ilkimen
2019-11-11 04:49:35 +01:00
parent b3276ad2d4
commit 594d03aa41
12 changed files with 348 additions and 50 deletions
+25 -4
View File
@@ -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);
}
}
};