camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-8941) Restlet supports binary files only with media type application/octet-stream
Date Sun, 12 Jul 2015 13:15:04 GMT

    [ 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)

Mime
View raw message