You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cm...@apache.org on 2013/05/27 23:11:00 UTC
git commit: CAMEL-6402: HTTP4 - Set the content length for requests,
if known Thanks to Chris Geer for the patch
Updated Branches:
refs/heads/master 42d431f80 -> 1995e574c
CAMEL-6402: HTTP4 - Set the content length for requests, if known
Thanks to Chris Geer for the patch
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1995e574
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1995e574
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1995e574
Branch: refs/heads/master
Commit: 1995e574cc5727ba950cefa37c965201a8acdd2e
Parents: 42d431f
Author: cmueller <cm...@apache.org>
Authored: Mon May 27 23:10:38 2013 +0200
Committer: cmueller <cm...@apache.org>
Committed: Mon May 27 23:10:38 2013 +0200
----------------------------------------------------------------------
.../java/org/apache/camel/util/GZIPHelper.java | 4 +---
.../camel/component/http4/HttpEntityConverter.java | 10 +++++++---
2 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/1995e574/camel-core/src/main/java/org/apache/camel/util/GZIPHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/GZIPHelper.java b/camel-core/src/main/java/org/apache/camel/util/GZIPHelper.java
index d615260..c016d9a 100644
--- a/camel-core/src/main/java/org/apache/camel/util/GZIPHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/GZIPHelper.java
@@ -42,9 +42,8 @@ public final class GZIPHelper {
return in;
}
}
-
- public static InputStream compressGzip(String contentEncoding, InputStream in) throws IOException {
+ public static InputStream compressGzip(String contentEncoding, InputStream in) throws IOException {
if (isGzip(contentEncoding)) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
GZIPOutputStream gzip = new GZIPOutputStream(os);
@@ -59,7 +58,6 @@ public final class GZIPHelper {
} else {
return in;
}
-
}
public static InputStream compressGzip(String contentEncoding, byte[] data) throws IOException {
http://git-wip-us.apache.org/repos/asf/camel/blob/1995e574/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 5991e65..e88ceb5 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
@@ -61,7 +61,9 @@ public final class HttpEntityConverter {
InputStreamEntity entity;
if (!exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
- entity = new InputStreamEntity(GZIPHelper.compressGzip(contentEncoding, in), -1);
+ InputStream stream = GZIPHelper.compressGzip(contentEncoding, in);
+ entity = new InputStreamEntity(stream, stream instanceof ByteArrayInputStream
+ ? stream.available() != 0 ? stream.available() : -1 : -1);
} else {
entity = new InputStreamEntity(in, -1);
}
@@ -78,9 +80,11 @@ public final class HttpEntityConverter {
InputStreamEntity entity;
if (exchange != null && !exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
- entity = new InputStreamEntity(GZIPHelper.compressGzip(contentEncoding, data), -1);
+ 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), -1);
+ entity = new InputStreamEntity(new ByteArrayInputStream(data), data.length);
}
if (exchange != null) {
String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);