add response type "arraybuffer" support for iOS

This commit is contained in:
Sefa Ilkimen
2019-06-12 23:43:40 +02:00
parent f91727e14a
commit 8cf0d21a7a
9 changed files with 198 additions and 24 deletions
+15 -1
View File
@@ -642,7 +642,7 @@ const tests = [
}
},
{
description: 'should fetch binary correctly when response type "arraybuffer" is given',
description: 'should fetch binary correctly when response type is "arraybuffer"',
expected: 'resolved: {"hash":-1032603775,"byteLength":35588}',
func: function (resolve, reject) {
var url = 'https://httpbin.org/image/jpeg';
@@ -660,6 +660,20 @@ const tests = [
result.data.hash.should.be.equal(-1032603775);
result.data.byteLength.should.be.equal(35588);
}
},
{
description: 'should decode error body even if response type is "arraybuffer"',
expected: 'rejected: {"status": 418, ...',
func: function (resolve, reject) {
var url = 'https://httpbin.org/status/418';
var options = { method: 'get', responseType: 'arraybuffer' };
cordova.plugin.http.sendRequest(url, options, resolve, reject);
},
validationFunc: function (driver, result) {
result.type.should.be.equal('rejected');
result.data.status.should.be.equal(418);
result.data.error.should.be.equal("\n -=[ teapot ]=-\n\n _...._\n .' _ _ `.\n | .\"` ^ `\". _,\n \\_;`\"---\"`|//\n | ;/\n \\_ _/\n `\"\"\"`\n");
}
}
// @TODO: not ready yet
// {