You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/02/26 06:47:52 UTC
[camel] 01/06: camel-http - polished
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit b7c718a0306bd3bfae4a2e9b6b21dd99db1144ea
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Feb 26 06:53:12 2021 +0100
camel-http - polished
---
.../camel/component/http/HttpEntityConverter.java | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEntityConverter.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEntityConverter.java
index 7ed5dd2..8302d0d 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEntityConverter.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEntityConverter.java
@@ -61,7 +61,7 @@ public final class HttpEntityConverter {
private static HttpEntity asHttpEntity(InputStream in, Exchange exchange) throws IOException {
InputStreamEntity entity;
- if (!exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
+ 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, in);
entity = new InputStreamEntity(
@@ -72,9 +72,13 @@ public final class HttpEntityConverter {
}
if (exchange != null) {
String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
+ if (contentEncoding != null) {
+ entity.setContentEncoding(contentEncoding);
+ }
String contentType = ExchangeHelper.getContentType(exchange);
- entity.setContentEncoding(contentEncoding);
- entity.setContentType(contentType);
+ if (contentType != null) {
+ entity.setContentType(contentType);
+ }
}
return entity;
}
@@ -93,9 +97,13 @@ public final class HttpEntityConverter {
}
if (exchange != null) {
String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
+ if (contentEncoding != null) {
+ entity.setContentEncoding(contentEncoding);
+ }
String contentType = ExchangeHelper.getContentType(exchange);
- entity.setContentEncoding(contentEncoding);
- entity.setContentType(contentType);
+ if (contentType != null) {
+ entity.setContentType(contentType);
+ }
}
return entity;
}