cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject js commit: [CB-861] Header support for FileTransfer download
Date Thu, 28 Feb 2013 18:07:12 GMT
Updated Branches:
  refs/heads/master c5437f050 -> 6049d6674


[CB-861] Header support for FileTransfer download

Added support for an optional options object as the final arg. Currently only handles the
options.headers object (as per the issue).

`FileTransfer.download(source, target, successCallback, errorCallback, trustAllHosts, options)`

This is needed for using FileTransfer.download with Basic Authentication, etc. Sadly since
Android 2.x doesn't support XHR2, this is needed in FileTransfer.

I have only added support to Android and iOS (see other PR's).


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/6049d667
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/6049d667
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/6049d667

Branch: refs/heads/master
Commit: 6049d66747221874bd1e6821b4f3690faa60ab99
Parents: c5437f0
Author: Tommy-Carlos Williams <tommy@devgeeks.org>
Authored: Sun Feb 24 14:52:17 2013 +1100
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Thu Feb 28 13:06:40 2013 -0500

----------------------------------------------------------------------
 lib/common/plugin/FileTransfer.js |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6049d667/lib/common/plugin/FileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/FileTransfer.js b/lib/common/plugin/FileTransfer.js
index 3a9fda2..778f955 100644
--- a/lib/common/plugin/FileTransfer.js
+++ b/lib/common/plugin/FileTransfer.js
@@ -103,10 +103,17 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback,
erro
  * @param successCallback (Function}  Callback to be invoked when upload has completed
  * @param errorCallback {Function}    Callback to be invoked upon error
  * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs),
defaults to false
+ * @param options {FileDownloadOptions} Optional parameters such as headers
  */
-FileTransfer.prototype.download = function(source, target, successCallback, errorCallback,
trustAllHosts) {
+FileTransfer.prototype.download = function(source, target, successCallback, errorCallback,
trustAllHosts, options) {
     argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments);
     var self = this;
+
+    var headers = null;
+    if (options) {
+        headers = options.headers || null;
+    }
+
     var win = function(result) {
         if (typeof result.lengthComputable != "undefined") {
             if (self.onprogress) {
@@ -133,7 +140,7 @@ FileTransfer.prototype.download = function(source, target, successCallback,
erro
         errorCallback(error);
     };
 
-    exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id]);
+    exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id,
headers]);
 };
 
 /**


Mime
View raw message