CB-10974 Cordova file transfer Content-Length header problem

Don't force chunkedMode=true for HTTPS if it was specified as false in the 
UploadOptions (added a warning about possible OOM for chunkedMode=false+HTTPS 
case)


Project: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/65548990
Tree: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/65548990
Diff: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/65548990

Branch: refs/heads/1.6.x
Commit: 655489905ab5bd2600d4eaf80e8dd5d27e96b461
Parents: 9b322de
Author: daserge <[email protected]>
Authored: Wed Nov 23 14:33:32 2016 +0300
Committer: daserge <[email protected]>
Committed: Wed Nov 23 14:33:32 2016 +0300

----------------------------------------------------------------------
 src/android/FileTransfer.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/65548990/src/android/FileTransfer.java
----------------------------------------------------------------------
diff --git a/src/android/FileTransfer.java b/src/android/FileTransfer.java
index f9c2037..de15981 100644
--- a/src/android/FileTransfer.java
+++ b/src/android/FileTransfer.java
@@ -430,7 +430,7 @@ public class FileTransfer extends CordovaPlugin {
                     // setFixedLengthStreamingMode causes and 
OutOfMemoryException on pre-Froyo devices.
                     // http://code.google.com/p/android/issues/detail?id=3164
                     // It also causes OOM if HTTPS is used, even on newer 
devices.
-                    boolean useChunkedMode = chunkedMode || 
(Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO || useHttps);
+                    boolean useChunkedMode = chunkedMode || 
(Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO);
                     useChunkedMode = useChunkedMode || (fixedLength == -1);
 
                     if (useChunkedMode) {
@@ -440,6 +440,10 @@ public class FileTransfer extends CordovaPlugin {
                         conn.setRequestProperty("Transfer-Encoding", 
"chunked");
                     } else {
                         conn.setFixedLengthStreamingMode(fixedLength);
+
+                        if (useHttps) {
+                            LOG.w(LOG_TAG, "setFixedLengthStreamingMode could 
cause OutOfMemoryException - switch to chunkedMode=true to avoid it if this is 
an issue.");
+                        }
                     }
 
                     conn.connect();
@@ -565,7 +569,6 @@ public class FileTransfer extends CordovaPlugin {
 
                     if (conn != null) {
                         // Revert back to the proper verifier and socket 
factories
-                        // Revert back to the proper verifier and socket 
factories
                         if (trustEveryone && useHttps) {
                             HttpsURLConnection https = (HttpsURLConnection) 
conn;
                             https.setHostnameVerifier(oldHostnameVerifier);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to