hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r544121 - /jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
Date Mon, 04 Jun 2007 11:16:24 GMT
Author: olegk
Date: Mon Jun  4 04:16:24 2007
New Revision: 544121

URL: http://svn.apache.org/viewvc?view=rev&rev=544121
Log:
Fixed HEAD request handling

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java?view=diff&rev=544121&r1=544120&r2=544121
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
Mon Jun  4 04:16:24 2007
@@ -543,6 +543,10 @@
 
         this.httpProcessor.process(response, context);
 
+        if (!canResponseHaveBody(request, response)) {
+            response.setEntity(null);
+        }
+        
         connState.setResponse(response);
         // Response is ready to be committed
         conn.requestOutput();
@@ -558,6 +562,20 @@
         }
     }
     
+    private boolean canResponseHaveBody(
+            final HttpRequest request, final HttpResponse response) {
+
+        if (request != null && "HEAD".equalsIgnoreCase(request.getRequestLine().getMethod()))
{
+            return false;
+        }
+        
+        int status = response.getStatusLine().getStatusCode(); 
+        return status >= HttpStatus.SC_OK 
+            && status != HttpStatus.SC_NO_CONTENT 
+            && status != HttpStatus.SC_NOT_MODIFIED
+            && status != HttpStatus.SC_RESET_CONTENT; 
+    }
+
     static class ServerConnState {
         
         public static final int SHUTDOWN                   = -1;



Mime
View raw message