hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r941904 - in /httpcomponents/httpcore/trunk/httpcore-contrib/src/main/java/org/apache/http/contrib/compress: ResponseGzipCompress.java ResponseGzipUncompress.java
Date Thu, 06 May 2010 20:39:03 GMT
Author: olegk
Date: Thu May  6 20:39:03 2010
New Revision: 941904

URL: http://svn.apache.org/viewvc?rev=941904&view=rev
Log:
Check for entity being non null

Modified:
    httpcomponents/httpcore/trunk/httpcore-contrib/src/main/java/org/apache/http/contrib/compress/ResponseGzipCompress.java
    httpcomponents/httpcore/trunk/httpcore-contrib/src/main/java/org/apache/http/contrib/compress/ResponseGzipUncompress.java

Modified: httpcomponents/httpcore/trunk/httpcore-contrib/src/main/java/org/apache/http/contrib/compress/ResponseGzipCompress.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-contrib/src/main/java/org/apache/http/contrib/compress/ResponseGzipCompress.java?rev=941904&r1=941903&r2=941904&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-contrib/src/main/java/org/apache/http/contrib/compress/ResponseGzipCompress.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-contrib/src/main/java/org/apache/http/contrib/compress/ResponseGzipCompress.java
Thu May  6 20:39:03 2010
@@ -31,6 +31,7 @@ import java.io.IOException;
 
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
+import org.apache.http.HttpEntity;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
@@ -54,18 +55,19 @@ public class ResponseGzipCompress implem
         if (context == null) {
             throw new IllegalArgumentException("HTTP context may not be null");
         }
-        HttpRequest request = (HttpRequest)
-            context.getAttribute(ExecutionContext.HTTP_REQUEST);
-        Header aeheader = request.getFirstHeader(ACCEPT_ENCODING);
-        if (aeheader != null) {
-            HeaderElement[] codecs = aeheader.getElements();
-            for (int i = 0; i < codecs.length; i++) {
-                if (codecs[i].getName().equalsIgnoreCase(GZIP_CODEC)) {
-                    response.setEntity(new GzipCompressingEntity(response.getEntity()));
-                    return;
+        HttpEntity entity = response.getEntity();
+        if (entity != null) {
+            HttpRequest request = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
+            Header aeheader = request.getFirstHeader(ACCEPT_ENCODING);
+            if (aeheader != null) {
+                HeaderElement[] codecs = aeheader.getElements();
+                for (int i = 0; i < codecs.length; i++) {
+                    if (codecs[i].getName().equalsIgnoreCase(GZIP_CODEC)) {
+                        response.setEntity(new GzipCompressingEntity(entity));
+                        return;
+                    }
                 }
             }
         }
     }
-
 }

Modified: httpcomponents/httpcore/trunk/httpcore-contrib/src/main/java/org/apache/http/contrib/compress/ResponseGzipUncompress.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-contrib/src/main/java/org/apache/http/contrib/compress/ResponseGzipUncompress.java?rev=941904&r1=941903&r2=941904&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-contrib/src/main/java/org/apache/http/contrib/compress/ResponseGzipUncompress.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-contrib/src/main/java/org/apache/http/contrib/compress/ResponseGzipUncompress.java
Thu May  6 20:39:03 2010
@@ -53,13 +53,15 @@ public class ResponseGzipUncompress impl
             throw new IllegalArgumentException("HTTP context may not be null");
         }
         HttpEntity entity = response.getEntity();
-        Header ceheader = entity.getContentEncoding();
-        if (ceheader != null) {
-            HeaderElement[] codecs = ceheader.getElements();
-            for (int i = 0; i < codecs.length; i++) {
-                if (codecs[i].getName().equalsIgnoreCase(GZIP_CODEC)) {
-                    response.setEntity(new GzipDecompressingEntity(response.getEntity()));
-                    return;
+        if (entity != null) {
+            Header ceheader = entity.getContentEncoding();
+            if (ceheader != null) {
+                HeaderElement[] codecs = ceheader.getElements();
+                for (int i = 0; i < codecs.length; i++) {
+                    if (codecs[i].getName().equalsIgnoreCase(GZIP_CODEC)) {
+                        response.setEntity(new GzipDecompressingEntity(response.getEntity()));
+                        return;
+                    }
                 }
             }
         }



Mime
View raw message