You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2012/08/16 16:30:17 UTC
android commit: Fix FileTransfer running out of memory over HTTPS
(CB-312).
Updated Branches:
refs/heads/master e42913ae8 -> 999c548e6
Fix FileTransfer running out of memory over HTTPS (CB-312).
Setting the Transfer-Encoding header fixes running out of memory when
using HTTPS.
This CL also adds a bit of logging so that upload progress is logged.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/999c548e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/999c548e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/999c548e
Branch: refs/heads/master
Commit: 999c548e6e29c9253403dbfc9f340c1c52c89871
Parents: e42913a
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Aug 16 10:25:54 2012 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Aug 16 10:30:04 2012 -0400
----------------------------------------------------------------------
framework/src/org/apache/cordova/FileTransfer.java | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/999c548e/framework/src/org/apache/cordova/FileTransfer.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileTransfer.java b/framework/src/org/apache/cordova/FileTransfer.java
index 61fa284..b64bc50 100644
--- a/framework/src/org/apache/cordova/FileTransfer.java
+++ b/framework/src/org/apache/cordova/FileTransfer.java
@@ -251,6 +251,7 @@ public class FileTransfer extends Plugin {
} else {
conn.setFixedLengthStreamingMode(fixedLength);
}
+ conn.setRequestProperty("Transfer-Encoding", "chunked");
dos = new DataOutputStream( conn.getOutputStream() );
//We don't want to change encoding, we just want this to write for all Unicode.
@@ -267,10 +268,15 @@ public class FileTransfer extends Plugin {
bytesRead = fileInputStream.read(buffer, 0, bufferSize);
totalBytes = 0;
+ long prevBytesRead = 0;
while (bytesRead > 0) {
totalBytes += bytesRead;
result.setBytesSent(totalBytes);
dos.write(buffer, 0, bufferSize);
+ if (totalBytes > prevBytesRead + 102400) {
+ prevBytesRead = totalBytes;
+ Log.d(LOG_TAG, "Uploaded " + totalBytes + " of " + fixedLength + " bytes");
+ }
bytesAvailable = fileInputStream.available();
bufferSize = Math.min(bytesAvailable, maxBufferSize);
bytesRead = fileInputStream.read(buffer, 0, bufferSize);