hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1676713 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/client/protocol/ResponseContentEncoding.java test/java/org/apache/http/client/protocol/TestResponseContentEncoding.java
Date Wed, 29 Apr 2015 10:32:24 GMT
Author: olegk
Date: Wed Apr 29 10:32:24 2015
New Revision: 1676713

URL: http://svn.apache.org/r1676713
Log:
HTTPCLIENT-1643: tolerate unknown content encodings by default

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseContentEncoding.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java?rev=1676713&r1=1676712&r2=1676713&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java
Wed Apr 29 10:32:24 2015
@@ -78,17 +78,33 @@ public class ResponseContentEncoding imp
     };
 
     private final Lookup<InputStreamFactory> decoderRegistry;
+    private final boolean ignoreUnknown;
 
     /**
-     * @since 4.4
+     * @since 4.5
      */
-    public ResponseContentEncoding(final Lookup<InputStreamFactory> decoderRegistry)
{
+    public ResponseContentEncoding(final Lookup<InputStreamFactory> decoderRegistry,
final boolean ignoreUnknown) {
         this.decoderRegistry = decoderRegistry != null ? decoderRegistry :
             RegistryBuilder.<InputStreamFactory>create()
                     .register("gzip", GZIP)
                     .register("x-gzip", GZIP)
                     .register("deflate", DEFLATE)
                     .build();
+        this.ignoreUnknown = ignoreUnknown;
+    }
+
+    /**
+     * @since 4.5
+     */
+    public ResponseContentEncoding(final boolean ignoreUnknown) {
+        this(null, ignoreUnknown);
+    }
+
+    /**
+     * @since 4.4
+     */
+    public ResponseContentEncoding(final Lookup<InputStreamFactory> decoderRegistry)
{
+        this(decoderRegistry, true);
     }
 
     /**
@@ -126,7 +142,7 @@ public class ResponseContentEncoding imp
                         response.removeHeaders("Content-Encoding");
                         response.removeHeaders("Content-MD5");
                     } else {
-                        if (!"identity".equals(codecname)) {
+                        if (!"identity".equals(codecname) && !ignoreUnknown) {
                             throw new HttpException("Unsupported Content-Coding: " + codec.getName());
                         }
                     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseContentEncoding.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseContentEncoding.java?rev=1676713&r1=1676712&r2=1676713&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseContentEncoding.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseContentEncoding.java
Wed Apr 29 10:32:24 2015
@@ -151,7 +151,7 @@ public class TestResponseContentEncoding
         response.setEntity(original);
         final HttpContext context = new BasicHttpContext();
 
-        final HttpResponseInterceptor interceptor = new ResponseContentEncoding();
+        final HttpResponseInterceptor interceptor = new ResponseContentEncoding(false);
         interceptor.process(response, context);
     }
 



Mime
View raw message