Q:

Camel: how to predict HTTP charchester encoding when doing conversion

Doing this way:
from("direct:foo").
to("http://foo.com/bar.html").
convertBodyTo(String.class, "cp1251").
to("file:///tmp/bar.html")

However some pages I crawl could have encoding different from cp1251. How to determine encoding (either using Content-Type HTTP header or meta/@http-equiv' charset) and call convertBodyTo() using appropriate charset? May be Camel HTTP component could do that? What's Exchange.HTTP_CHARACTER_ENCODING?

A:

You can add processor to set the exchange property with the header Exchange.CHARSET_NAME, the value could be information you get from the Http header content-type.
At this point, camel can know the encoding it can use.

