incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject android commit: Fix broken file upload in mobile-spec tests (CB-1290).
Date Thu, 30 Aug 2012 17:38:02 GMT
Updated Branches:
  refs/heads/master f7ae7fe43 -> c3e17fb18


Fix broken file upload in mobile-spec tests (CB-1290).

The explicit transfer-encoding: chunk that was added breaks in
fixed-length streaming mode. It is, however, still required to
work-around an OOM bug in HTTPS mode. The new logic works for both the
mobile-spec and the HTTPS large-file test that I used before.

Commit adding the header: 999c548e6e29c9253403dbfc9f340c1c52c89871


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/c3e17fb1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/c3e17fb1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/c3e17fb1

Branch: refs/heads/master
Commit: c3e17fb185afddefe05accaa713cba7e0cb52e00
Parents: f7ae7fe
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Thu Aug 30 13:33:06 2012 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Thu Aug 30 13:37:19 2012 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/FileTransfer.java |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c3e17fb1/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 b64bc50..ce7120b 100644
--- a/framework/src/org/apache/cordova/FileTransfer.java
+++ b/framework/src/org/apache/cordova/FileTransfer.java
@@ -146,9 +146,9 @@ public class FileTransfer extends Plugin {
             //------------------ CLIENT REQUEST
             // open a URL connection to the server
             URL url = new URL(target);
-
+            boolean useHttps = url.getProtocol().toLowerCase().equals("https");
             // Open a HTTP connection to the URL based on protocol
-            if (url.getProtocol().toLowerCase().equals("https")) {
+            if (useHttps) {
                 // Using standard HTTPS connection. Will not allow self signed certificate
                 if (!trustEveryone) {
                     conn = (HttpsURLConnection) url.openConnection();
@@ -246,12 +246,17 @@ public class FileTransfer extends Plugin {
             Log.d(LOG_TAG, "Content Length: " + fixedLength);
             // setFixedLengthStreamingMode causes and OutOfMemoryException on pre-Froyo devices.
             // http://code.google.com/p/android/issues/detail?id=3164
-            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO && chunkedMode)
{
+            // It also causes OOM if HTTPS is used, even on newer devices.
+            chunkedMode = chunkedMode && (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO
|| useHttps);
+            		
+            if (chunkedMode) {
                 conn.setChunkedStreamingMode(maxBufferSize);
+                // Although setChunkedStreamingMode sets this header, setting it explicitly
here works
+                // around an OutOfMemoryException when using https.
+                conn.setRequestProperty("Transfer-Encoding", "chunked");
             } 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.


Mime
View raw message