CAMEL-7757 Fix the EOFException in camel-restlet with thanks to Sandeep
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ad962478 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ad962478 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ad962478 Branch: refs/heads/camel-2.12.x Commit: ad9624787ccacd232c6edeeb158c1d0321a90e4b Parents: 986ebbd Author: Willem Jiang <willem.ji...@gmail.com> Authored: Thu Aug 28 14:31:15 2014 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Fri Aug 29 13:04:22 2014 +0800 ---------------------------------------------------------------------- .../component/restlet/DefaultRestletBinding.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/ad962478/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 ebef445..cd3d62d 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 @@ -299,13 +299,17 @@ public class DefaultRestletBinding implements RestletBinding, HeaderFilterStrate // get content type MediaType mediaType = response.getEntity().getMediaType(); if (mediaType != null) { + LOG.debug("Setting the Content-Type to be {}", mediaType.toString()); exchange.getOut().setHeader(Exchange.CONTENT_TYPE, mediaType.toString()); } - - // get content text - String text = response.getEntity().getText(); - LOG.debug("Populate exchange from Restlet response: {}", text); - exchange.getOut().setBody(text); + if (mediaType != null && mediaType.equals(MediaType.APPLICATION_OCTET_STREAM)) { + exchange.getOut().setBody(response.getEntity().getStream()); + } else { + // get content text + String text = response.getEntity().getText(); + LOG.debug("Populate exchange from Restlet response: {}", text); + exchange.getOut().setBody(text); + } } // preserve headers from in by copying any non existing headers