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
The following commit(s) were added to refs/heads/master by this push:
new c26065e Backport fix for
https://github.com/apache/camel-k-runtime/issues/301 into
camel-platform-http-vertx (#3749)
c26065e is described below
commit c26065ed4c7dd04e160ad4d08dea89f8f4cf872a
Author: Nicola Ferraro <[email protected]>
AuthorDate: Thu Apr 16 20:52:17 2020 +0200
Backport fix for https://github.com/apache/camel-k-runtime/issues/301 into
camel-platform-http-vertx (#3749)
---
.../platform/http/vertx/VertxPlatformHttpSupport.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git
a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java
b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java
index ddf3760..61277a7 100644
---
a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java
+++
b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpSupport.java
@@ -110,6 +110,14 @@ public final class VertxPlatformHttpSupport {
ExchangeHelper.setFailureHandled(exchange);
}
+ // set the content-length if it can be determined, or chunked encoding
+ final Integer length = determineContentLength(exchange, body);
+ if (length != null) {
+ response.putHeader("Content-Length", String.valueOf(length));
+ } else {
+ response.setChunked(true);
+ }
+
// set the content type in the response.
final String contentType = MessageHelper.getContentType(message);
if (contentType != null) {
@@ -119,6 +127,15 @@ public final class VertxPlatformHttpSupport {
return body;
}
+ static Integer determineContentLength(Exchange camelExchange, Object body)
{
+ if (body instanceof byte[]) {
+ return ((byte[]) body).length;
+ } else if (body instanceof ByteBuffer) {
+ return ((ByteBuffer) body).remaining();
+ }
+ return null;
+ }
+
/*
* Copied from
org.apache.camel.http.common.DefaultHttpBinding.determineResponseCode(Exchange,
Object)
* If DefaultHttpBinding.determineResponseCode(Exchange, Object) is moved
to a module without the servlet-api