hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1348896 - in /httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http: client/protocol/ResponseContentEncoding.java impl/client/DecompressingHttpClient.java
Date Mon, 11 Jun 2012 15:12:54 GMT
Author: olegk
Date: Mon Jun 11 15:12:54 2012
New Revision: 1348896

URL: http://svn.apache.org/viewvc?rev=1348896&view=rev
Log:
Moved content header handling logic from DecompressingHttpClient to ResponseContentEncoding
intertceptor

Modified:
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java
    httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java?rev=1348896&r1=1348895&r2=1348896&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java
Mon Jun 11 15:12:54 2012
@@ -78,16 +78,15 @@ public class ResponseContentEncoding imp
             Header ceheader = entity.getContentEncoding();
             if (ceheader != null) {
                 HeaderElement[] codecs = ceheader.getElements();
+                boolean uncompressed = false;
                 for (HeaderElement codec : codecs) {
                     String codecname = codec.getName().toLowerCase(Locale.US);
                     if ("gzip".equals(codecname) || "x-gzip".equals(codecname)) {
                         response.setEntity(new GzipDecompressingEntity(response.getEntity()));
-                        if (context != null) context.setAttribute(UNCOMPRESSED, true);  
-                        return;
+                        break;
                     } else if ("deflate".equals(codecname)) {
                         response.setEntity(new DeflateDecompressingEntity(response.getEntity()));
-                        if (context != null) context.setAttribute(UNCOMPRESSED, true);
-                        return;
+                        break;
                     } else if ("identity".equals(codecname)) {
 
                         /* Don't need to transform the content - no-op */
@@ -96,6 +95,11 @@ public class ResponseContentEncoding imp
                         throw new HttpException("Unsupported Content-Coding: " + codec.getName());
                     }
                 }
+                if (uncompressed) {
+                    response.removeHeaders("Content-Length");
+                    response.removeHeaders("Content-Encoding");
+                    response.removeHeaders("Content-MD5");
+                }
             }
         }
     }

Modified: httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java?rev=1348896&r1=1348895&r2=1348896&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java
(original)
+++ httpcomponents/httpclient/branches/decorator-refactoring/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java
Mon Jun 11 15:12:54 2012
@@ -136,11 +136,6 @@ public class DecompressingHttpClient imp
             acceptEncodingInterceptor.process(wrapped, context);
             HttpResponse response = backend.execute(target, wrapped, context);
             contentEncodingInterceptor.process(response, context);
-            if (Boolean.TRUE.equals(context.getAttribute(ResponseContentEncoding.UNCOMPRESSED)))
{
-                response.removeHeaders("Content-Length");
-                response.removeHeaders("Content-Encoding");
-                response.removeHeaders("Content-MD5");
-            }
             return response;
         } catch (HttpException e) {
             throw new ClientProtocolException(e);



Mime
View raw message