You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/05/09 20:03:03 UTC
[12/50] httpcomponents-core git commit: HTTPCORE-328,
HTTPCORE-329: EntityUtils#toString ignores the default charset if
there is no ContentType in a http response
HTTPCORE-328, HTTPCORE-329: EntityUtils#toString ignores the default charset if there is no ContentType in a http response
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.2.x@1435088 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/0b9f6cb1
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/0b9f6cb1
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/0b9f6cb1
Branch: refs/heads/4.2.x
Commit: 0b9f6cb13bd7e57016767d1cb6b4d787c4ccb93c
Parents: a64b98c
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Fri Jan 18 11:11:22 2013 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Fri Jan 18 11:11:22 2013 +0000
----------------------------------------------------------------------
httpcore/src/main/java/org/apache/http/util/EntityUtils.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/0b9f6cb1/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/util/EntityUtils.java b/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
index 8739cdd..85bc830 100644
--- a/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
+++ b/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
@@ -213,9 +213,11 @@ public final class EntityUtils {
}
Charset charset = null;
try {
- ContentType contentType = ContentType.getOrDefault(entity);
- charset = contentType.getCharset();
- } catch (UnsupportedCharsetException ex) {
+ ContentType contentType = ContentType.get(entity);
+ if (contentType != null) {
+ charset = contentType.getCharset();
+ }
+ } catch (final UnsupportedCharsetException ex) {
throw new UnsupportedEncodingException(ex.getMessage());
}
if (charset == null) {