You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/09/21 14:13:11 UTC

git commit: CAMEL-7842 Avoid using InputStreamEntity for byte[] input

Repository: camel
Updated Branches:
  refs/heads/master 88cc247ed -> 0282a13b8


CAMEL-7842 Avoid using InputStreamEntity for byte[] input


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0282a13b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0282a13b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0282a13b

Branch: refs/heads/master
Commit: 0282a13b876989904e2cc3ce5739eb5410620e13
Parents: 88cc247
Author: Willem Jiang <wi...@gmail.com>
Authored: Sun Sep 21 20:11:59 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Sun Sep 21 20:11:59 2014 +0800

----------------------------------------------------------------------
 .../org/apache/camel/component/http4/HttpEntityConverter.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0282a13b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEntityConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEntityConverter.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEntityConverter.java
index e88ceb5..8236da8 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEntityConverter.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEntityConverter.java
@@ -25,6 +25,8 @@ import org.apache.camel.Exchange;
 import org.apache.camel.util.ExchangeHelper;
 import org.apache.camel.util.GZIPHelper;
 import org.apache.http.HttpEntity;
+import org.apache.http.entity.AbstractHttpEntity;
+import org.apache.http.entity.ByteArrayEntity;
 import org.apache.http.entity.InputStreamEntity;
 
 /**
@@ -77,14 +79,15 @@ public final class HttpEntityConverter {
     }
 
     private static HttpEntity asHttpEntity(byte[] data, Exchange exchange) throws Exception {
-        InputStreamEntity entity;
+        AbstractHttpEntity entity;
         if (exchange != null && !exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
             String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
             InputStream stream = GZIPHelper.compressGzip(contentEncoding, data);
             entity = new InputStreamEntity(stream, stream instanceof ByteArrayInputStream
                 ? stream.available() != 0 ? stream.available() : -1 : -1);
         } else {
-            entity = new InputStreamEntity(new ByteArrayInputStream(data), data.length);
+            // create the Repeatable HttpEntity
+            entity = new ByteArrayEntity(data);
         }
         if (exchange != null) {
             String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);