@Test
public void testUsingFunkyCharsetInContentTypeHeader() throws Exception {

    final String test =
            "<html><head><title>the name is \u00e1ndre</title></head>"
                    + "<body></body></html>";
    Metadata metadata = new Metadata();
    new HtmlParser().parse(
            new ByteArrayInputStream(test.getBytes(UTF_8)),
            new BodyContentHandler(), metadata, new ParseContext());
    assertEquals("UTF-8", metadata.get(Metadata.CONTENT_ENCODING));
    metadata = new Metadata();
    metadata.set(Metadata.CONTENT_TYPE, "charset=ISO-8859-1;text/html");
    new HtmlParser().parse(
            new ByteArrayInputStream(test.getBytes(ISO_8859_1)),
            new BodyContentHandler(), metadata, new ParseContext());
    assertEquals("ISO-8859-1", metadata.get(Metadata.CONTENT_ENCODING));
}