Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D8FCB18549 for ; Sun, 12 Jul 2015 13:15:04 +0000 (UTC) Received: (qmail 85178 invoked by uid 500); 12 Jul 2015 13:15:04 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 85132 invoked by uid 500); 12 Jul 2015 13:15:04 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 85122 invoked by uid 99); 12 Jul 2015 13:15:04 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Jul 2015 13:15:04 +0000 Date: Sun, 12 Jul 2015 13:15:04 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CAMEL-8941) Restlet supports binary files only with media type application/octet-stream MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-8941?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14623798#comment-14623798 ] ASF GitHub Bot commented on CAMEL-8941: --------------------------------------- Github user koscejev closed the pull request at: https://github.com/apache/camel/pull/558 > Restlet supports binary files only with media type application/octet-stream > ---------------------------------------------------------------------------- > > Key: CAMEL-8941 > URL: https://issues.apache.org/jira/browse/CAMEL-8941 > Project: Camel > Issue Type: Improvement > Components: camel-restlet > Affects Versions: 2.15.2 > Reporter: Anton Koscejev > Assignee: Claus Ibsen > Fix For: 2.16.0 > > > The camel-restlet component populates Camel Exchange from Restlet Response via DefaultRestletBinding. However, it only properly reads binary contents if media type is "application/octet-stream". In all other cases it reads contents as String, even if contents are binary. For example, if the contents are of type "audio/wave" - a normal .wav file returned by a REST service - they would be read as a String, which results in an unplayable file. > See code extract: > {code} > if (mediaType != null && mediaType.equals(MediaType.APPLICATION_OCTET_STREAM)) { > exchange.getOut().setBody(response.getEntity().getStream()); > } else if (response.getEntity() instanceof Representation) { > Representation representationDecoded = new DecodeRepresentation(response.getEntity()); > exchange.getOut().setBody(representationDecoded.getText()); > } else { > // get content text by default > String text = response.getEntity().getText(); > LOG.debug("Populate exchange from Restlet response: {}", text); > exchange.getOut().setBody(text); > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)