Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-8941

Restlet supports binary files only with media type application/octet-stream

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.15.2
    • 2.16.0
    • camel-restlet
    • None
    • Unknown

    Description

      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:

      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);
      }
      

      Attachments

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              koscejev Anton Koscejev
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: