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:51:14 UTC
[3/4] git commit: CAMEL-7842 Avoid using InputStreamEntity for byte[]
input
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/97801146
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/97801146
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/97801146
Branch: refs/heads/camel-2.13.x
Commit: 978011461d929f96b185449c70fd8418baf7c786
Parents: 64aa22d
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:50:19 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/97801146/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);