[
https://issues.apache.org/jira/browse/CAMEL-8941?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-8941.
--------------------------------
Resolution: Fixed
Assignee: Claus Ibsen
Thanks for the PR
> 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)