[ https://issues.apache.org/jira/browse/HTTPCORE-329?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thomas Kruse updated HTTPCORE-329: ---------------------------------- Description: The method public static String toString( final HttpEntity entity, final String defaultCharset) delegates to public static String toString( final HttpEntity entity, final Charset defaultCharset) { ... ContentType contentType = ContentType.getOrDefault(entity); Charset charset = contentType.getCharset(); if (charset == null) { charset = defaultCharset; } ... } This method uses a default content type which has a charset set(!) public static ContentType getOrDefault(final HttpEntity entity) throws ParseException { ContentType contentType = get(entity); return contentType != null ? contentType : DEFAULT_TEXT; } public static final ContentType DEFAULT_TEXT = TEXT_PLAIN; public static final ContentType TEXT_PLAIN = create( "text/plain", Consts.ISO_8859_1); This leads to the situation that the defaultCharset is not used but latin1 encoding from the default content type. The default content type should not have an encoding set to prevent this. was: The method {code} public static String toString( final HttpEntity entity, final String defaultCharset) {code} delegates to {code} public static String toString( final HttpEntity entity, final Charset defaultCharset) { ... ContentType contentType = ContentType.getOrDefault(entity); Charset charset = contentType.getCharset(); if (charset == null) { charset = defaultCharset; } ... } {code} This method uses a default content type which has a charset set(!) {code} public static ContentType getOrDefault(final HttpEntity entity) throws ParseException { ContentType contentType = get(entity); return contentType != null ? contentType : DEFAULT_TEXT; } {code} {code} public static final ContentType DEFAULT_TEXT = TEXT_PLAIN; public static final ContentType TEXT_PLAIN = create( "text/plain", Consts.ISO_8859_1); {code} This leads to the situation that the defaultCharset is not used but latin1 encoding from the default content type. The default content type should not have an encoding set to prevent this. > EntityUtils.toString uses wrong charset if no content-type is provided by > server > -------------------------------------------------------------------------------- > > Key: HTTPCORE-329 > URL: https://issues.apache.org/jira/browse/HTTPCORE-329 > Project: HttpComponents HttpCore > Issue Type: Bug > Components: HttpCore > Affects Versions: 4.2.1 > Reporter: Thomas Kruse > > The method > public static String toString( final HttpEntity entity, final String > defaultCharset) > delegates to > public static String toString( final HttpEntity entity, final Charset > defaultCharset) { > ... > ContentType contentType = ContentType.getOrDefault(entity); > Charset charset = contentType.getCharset(); > if (charset == null) { > charset = defaultCharset; > } > ... > } > This method uses a default content type which has a charset set(!) > public static ContentType getOrDefault(final HttpEntity entity) throws > ParseException { > ContentType contentType = get(entity); > return contentType != null ? contentType : DEFAULT_TEXT; > } > public static final ContentType DEFAULT_TEXT = TEXT_PLAIN; > public static final ContentType TEXT_PLAIN = create( "text/plain", > Consts.ISO_8859_1); > This leads to the situation that the defaultCharset is not used but latin1 > encoding from the default content type. > The default content type should not have an encoding set to prevent this. -- 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 --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org