CAMEL-8941 fix: restlet consumer should allow returning binary data 
component-agnostic as InputStream or byte[]


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c1753c7b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c1753c7b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c1753c7b

Branch: refs/heads/master
Commit: c1753c7bb8222cc6caf66904affaca0eac4f6a8c
Parents: ad6f8c9
Author: Anton Koscejev <anton.kosce...@zoomint.com>
Authored: Fri Jul 10 17:20:16 2015 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Sun Jul 12 09:31:19 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/restlet/DefaultRestletBinding.java    | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c1753c7b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
----------------------------------------------------------------------
diff --git 
a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
 
b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
index 7a75e60..264093c 100644
--- 
a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
+++ 
b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
@@ -54,6 +54,7 @@ import org.restlet.data.Preference;
 import org.restlet.data.Status;
 import org.restlet.engine.application.DecodeRepresentation;
 import org.restlet.engine.header.HeaderConstants;
+import org.restlet.representation.ByteArrayRepresentation;
 import org.restlet.representation.FileRepresentation;
 import org.restlet.representation.InputRepresentation;
 import org.restlet.representation.Representation;
@@ -272,6 +273,9 @@ public class DefaultRestletBinding implements 
RestletBinding, HeaderFilterStrate
             response.setEntity(new 
InputRepresentation(out.getBody(InputStream.class), mediaType));
         } else if (body instanceof File) {
             response.setEntity(new FileRepresentation(out.getBody(File.class), 
mediaType));
+        } else if (body instanceof byte[]) {
+            byte[] bytes = out.getBody(byte[].class);
+            response.setEntity(new ByteArrayRepresentation(bytes, mediaType, 
bytes.length));
         } else {
             // fallback and use string
             String text = out.getBody(String.class);

Reply via email to