Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4F2D9DA23 for ; Fri, 3 Aug 2012 16:30:26 +0000 (UTC) Received: (qmail 83601 invoked by uid 500); 3 Aug 2012 16:30:26 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 83574 invoked by uid 500); 3 Aug 2012 16:30:26 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 83566 invoked by uid 99); 3 Aug 2012 16:30:26 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Aug 2012 16:30:26 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id CC5A01B9A4; Fri, 3 Aug 2012 16:30:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: android commit: Prefer setFixedLengthStreamingMode over setChunkedStreamingMode in FileTransfer. Message-Id: <20120803163025.CC5A01B9A4@tyr.zones.apache.org> Date: Fri, 3 Aug 2012 16:30:25 +0000 (UTC) Updated Branches: refs/heads/master 81ab0a414 -> af0feabb6 Prefer setFixedLengthStreamingMode over setChunkedStreamingMode in FileTransfer. setFixedLengthStreamingMode causes the Content-Length header to be set, which some servers require. We now use setChunkedStreamingMode only on Eclair devices since there is a bug with setFixedLengthStreamingMode in that version of the OS. 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/af0feabb Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/af0feabb Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/af0feabb Branch: refs/heads/master Commit: af0feabb6a32ac0ccb9bfd2ffc980725c4bf966c Parents: 81ab0a4 Author: Andrew Grieve Authored: Fri Jul 13 16:29:59 2012 -0400 Committer: Andrew Grieve Committed: Fri Aug 3 12:29:37 2012 -0400 ---------------------------------------------------------------------- framework/src/org/apache/cordova/FileTransfer.java | 21 +++++++-------- 1 files changed, 10 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/af0feabb/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 4adace5..6cde4b5 100644 --- a/framework/src/org/apache/cordova/FileTransfer.java +++ b/framework/src/org/apache/cordova/FileTransfer.java @@ -49,6 +49,7 @@ import org.json.JSONException; import org.json.JSONObject; import android.net.Uri; +import android.os.Build; import android.util.Log; import android.webkit.CookieManager; @@ -239,19 +240,17 @@ public class FileTransfer extends Plugin { String tailParams = LINE_END + LINE_START + BOUNDARY + LINE_START + LINE_END; byte[] fileNameBytes = fileName.getBytes("UTF-8"); - // Should set this up as an option - if (chunkedMode) { + int stringLength = extraBytes.length + midParams.length() + tailParams.length() + fileNameBytes.length; + Log.d(LOG_TAG, "String Length: " + stringLength); + int fixedLength = (int) fileInputStream.getChannel().size() + stringLength; + 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) { conn.setChunkedStreamingMode(maxBufferSize); + } else { + conn.setFixedLengthStreamingMode(fixedLength); } - else - { - int stringLength = extraBytes.length + midParams.length() + tailParams.length() + fileNameBytes.length; - Log.d(LOG_TAG, "String Length: " + stringLength); - int fixedLength = (int) fileInputStream.getChannel().size() + stringLength; - Log.d(LOG_TAG, "Content Length: " + fixedLength); - conn.setFixedLengthStreamingMode(fixedLength); - } - dos = new DataOutputStream( conn.getOutputStream() ); //We don't want to change encoding, we just want this to write for all Unicode.