I think we could add a check point to verify if the entity is Representation 
and using DecodeRepresentation to decode the representation.

In this way the user can get the decoded text from the message body directly.

I just created a JIRA for it[1].

[1] https://issues.apache.org/jira/browse/CAMEL-8078 

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On November 24, 2014 at 9:52:44 PM, sandp (sandeepred...@gmail.com) wrote:
> Hi,
> I just looked at the code on master
> https://github.com/apache/camel/blob/camel-2.14.x/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
>   
>  
> This code is different than the one in camel-restlet 2.14.0. Someone updated
> the file 5 days ago.
>  
> *The method starts at line number 311 on Master *. Below is the method from
> Master that I was talking about and it's the same as in 2.14.0
>  
> public void populateExchangeFromRestletResponse(Exchange exchange, Response  
> response) throws Exception {
> for (Map.Entry entry : response.getAttributes().entrySet())
> {
> String key = entry.getKey();
> Object value = entry.getValue();
> if (!headerFilterStrategy.applyFilterToExternalHeaders(key, value,
> exchange)) {
> exchange.getOut().setHeader(key, value);
> LOG.debug("Populate exchange from Restlet response header: {} value: {}",
> key, value);
> }
> }
> // set response code
> int responseCode = response.getStatus().getCode();
> exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, responseCode);
> // set restlet response as header so end user have access to it if needed
> exchange.getOut().setHeader(RestletConstants.RESTLET_RESPONSE, response);  
> if (response.getEntity() != null) {
> // 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());  
> }
> 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
> // to avoid overriding existing headers with old values
> MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), false);
> }
>  
>  
>  
>  
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Camel-Restlet-2-14-0-DecodeRepresentation-tp5759382p5759542.html
>   
> Sent from the Camel - Users mailing list archive at Nabble.com.
>  

Reply via email to