Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
4.2.1
-
None
-
None
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)
...
}
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.
Attachments
Issue Links
- duplicates
-
HTTPCORE-328 EntityUtils#toString ignores default charset parameter if there is no ContentType in the http response
- Closed