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 b91db4b camel-http - If payload is byte[] then use byte array entity
as its most optimal
b91db4b is described below
commit b91db4b410ba21552ee4ab0f483ea983dba75bd3
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Feb 25 20:26:04 2021 +0100
camel-http - If payload is byte[] then use byte array entity as its most
optimal
---
.../java/org/apache/camel/component/http/HttpProducer.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
index b789c40..39cf5f8 100644
---
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
+++
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
@@ -676,6 +676,12 @@ public class HttpProducer extends DefaultProducer {
answer = new FileEntity(file);
}
}
+ } else if (data instanceof byte[]) {
+ ByteArrayEntity entity = new ByteArrayEntity((byte[])
data);
+ if (contentType != null) {
+ entity.setContentType(contentType.toString());
+ }
+ answer = entity;
} else if (data instanceof String) {
// be a bit careful with String as any type can most
likely be converted to String
// so we only do an instanceof check and accept String
if the body is really a String
@@ -690,7 +696,9 @@ public class HttpProducer extends DefaultProducer {
}
}
StringEntity entity = new StringEntity((String) data,
charset);
- entity.setContentType(contentType != null ?
contentType.toString() : null);
+ if (contentType != null) {
+ entity.setContentType(contentType.toString());
+ }
answer = entity;
}