You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Willem Jiang (JIRA)" <ji...@apache.org> on 2013/03/20 14:59:17 UTC
[jira] [Assigned] (CAMEL-6188) CXF cosumer should set Exchange's
charset name, if content type provides one
[ https://issues.apache.org/jira/browse/CAMEL-6188?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Willem Jiang reassigned CAMEL-6188:
-----------------------------------
Assignee: Willem Jiang
> CXF cosumer should set Exchange's charset name, if content type provides one
> ----------------------------------------------------------------------------
>
> Key: CAMEL-6188
> URL: https://issues.apache.org/jira/browse/CAMEL-6188
> Project: Camel
> Issue Type: Bug
> Components: camel-cxf
> Affects Versions: 2.10.4
> Reporter: Fried Hoeben
> Assignee: Willem Jiang
>
> The CXF consumer copies the content-type http header to the camel exchange. This header may indicate the character set used in the request (for instance "text/xml;charset=UTF-8"), and if so this should be made available in the normal place for Camel (i.e. a property in the exchange called 'CamelCharsetName').
> This may (of course) be done in each route by a separate processor, but it simplifies life if this is done by default. (org.apache.camel.component.cxf.DefaultCxfBinding.populateExchangeFromCxfRequest() seems the logical place)
> Sample processor that performs this job.
> {code}
> import java.nio.charset.Charset;
> import org.apache.camel.Exchange;
> import org.apache.camel.Processor;
> import org.apache.camel.util.ExchangeHelper;
> import org.apache.http.entity.ContentType;
> /**
> * Processor to ensure the exchange's charset name property is in sync with
> * its content type.
> */
> public class CharsetProcessor implements Processor {
> @Override
> public void process(Exchange exchange) throws Exception {
> String contentTypeHeader = ExchangeHelper.getContentType(exchange);
> if (contentTypeHeader != null) {
> ContentType contentType = ContentType.parse(contentTypeHeader);
> if (contentType != null) {
> Charset charset = contentType.getCharset();
> exchange.setProperty(Exchange.CHARSET_NAME, charset.name());
> }
> }
> }
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira