CB-8721 Fixes incorrect headers and upload params parsing on wp8

This commit is contained in:
Vladimir Kotikov
2015-03-24 11:19:19 +03:00
parent 30eb233d53
commit 21fb03aa9c
2 changed files with 41 additions and 23 deletions
+23
View File
@@ -63,6 +63,20 @@ function getBasicAuthHeader(urlString) {
return header;
}
function convertHeadersToArray(headers) {
var result = [];
for (var header in headers) {
if (headers.hasOwnProperty(header)) {
var headerValue = headers[header];
result.push({
name: header,
value: headerValue.toString()
});
}
}
return result;
}
var idCounter = 0;
/**
@@ -125,6 +139,11 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
}
}
if (cordova.platformId === "windowsphone") {
headers = headers && convertHeadersToArray(headers);
params = params && convertHeadersToArray(params);
}
var fail = errorCallback && function(e) {
var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body, e.exception);
errorCallback(error);
@@ -170,6 +189,10 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro
headers = options.headers || null;
}
if (cordova.platformId === "windowsphone" && headers) {
headers = convertHeadersToArray(headers);
}
var win = function(result) {
if (typeof result.lengthComputable != "undefined") {
if (self.onprogress) {