camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/4] git commit: CAMEL-7842 Avoid using InputStreamEntity for byte[] input
Date Sun, 21 Sep 2014 12:51:13 GMT
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/fc99a62f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fc99a62f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fc99a62f

Branch: refs/heads/camel-2.14.x
Commit: fc99a62fdbdfa2ee54c7c9584e80e92df4b2b322
Parents: 57e2fa4
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Sun Sep 21 20:11:59 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Sun Sep 21 20:49:33 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/fc99a62f/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);


Mime
View raw message