CAMEL-8941 fix: restlet producer should handle binary streams regardless of 
content type


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

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

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


http://git-wip-us.apache.org/repos/asf/camel/blob/0054e73d/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 3d8df74..7a75e60 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
@@ -57,6 +57,7 @@ import org.restlet.engine.header.HeaderConstants;
 import org.restlet.representation.FileRepresentation;
 import org.restlet.representation.InputRepresentation;
 import org.restlet.representation.Representation;
+import org.restlet.representation.StreamRepresentation;
 import org.restlet.util.Series;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -334,8 +335,9 @@ public class DefaultRestletBinding implements 
RestletBinding, HeaderFilterStrate
                 LOG.debug("Setting the Content-Type to be {}",  
mediaType.toString());
                 exchange.getOut().setHeader(Exchange.CONTENT_TYPE, 
mediaType.toString());
             }
-            if (mediaType != null && 
mediaType.equals(MediaType.APPLICATION_OCTET_STREAM)) {
-                exchange.getOut().setBody(response.getEntity().getStream());
+            if (response.getEntity() instanceof StreamRepresentation) {
+                Representation representationDecoded = new 
DecodeRepresentation(response.getEntity());
+                exchange.getOut().setBody(representationDecoded.getStream());
             } else if (response.getEntity() instanceof Representation) {
                 Representation representationDecoded = new 
DecodeRepresentation(response.getEntity());
                 exchange.getOut().setBody(representationDecoded.getText());

Reply via email to