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 2013/01/18 12:12:08 UTC

svn commit: r1435089 - in /httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http: entity/InputStreamEntity.java util/EntityUtils.java

Author: olegk
Date: Fri Jan 18 11:12:08 2013
New Revision: 1435089

URL: http://svn.apache.org/viewvc?rev=1435089&view=rev
Log:
HTTPCORE-328, HTTPCORE-329: EntityUtils#toString ignores the default charset if there is no ContentType in a http response

Modified:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java?rev=1435089&r1=1435088&r2=1435089&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java Fri Jan 18 11:12:08 2013
@@ -54,7 +54,7 @@ public class InputStreamEntity extends A
      *
      * @param instream
      * @throws IllegalArgumentException if {@code instream} is {@code null}
-     * @since 4.4
+     * @since 4.3
      */
     public InputStreamEntity(final InputStream instream) {
         this(instream, -1);
@@ -78,7 +78,7 @@ public class InputStreamEntity extends A
      * @param instream
      * @param contentType
      * @throws IllegalArgumentException if {@code instream} is {@code null}
-     * @since 4.4
+     * @since 4.3
      */
     public InputStreamEntity(final InputStream instream, final ContentType contentType) {
         this(instream, -1, contentType);

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java?rev=1435089&r1=1435088&r2=1435089&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java Fri Jan 18 11:12:08 2013
@@ -224,8 +224,10 @@ public final class EntityUtils {
             }
             Charset charset = null;
             try {
-                final ContentType contentType = ContentType.getOrDefault(entity);
-                charset = contentType.getCharset();
+                final ContentType contentType = ContentType.get(entity);
+                if (contentType != null) {
+                    charset = contentType.getCharset();
+                }
             } catch (final UnsupportedCharsetException ex) {
                 throw new UnsupportedEncodingException(ex.getMessage());
             }