You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Kalnichevski (JIRA)" <ji...@apache.org> on 2013/01/16 15:38:13 UTC
[jira] [Resolved] (HTTPCORE-329) EntityUtils.toString uses wrong
charset if no content-type is provided by server
[ https://issues.apache.org/jira/browse/HTTPCORE-329?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oleg Kalnichevski resolved HTTPCORE-329.
----------------------------------------
Resolution: Duplicate
I believe this is a duplicate of HTTPCORE-328
Oleg
> 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-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org