hc-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?view=rev&rev=544120
Log:
Cleaned up HTTP protocol exception handling

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java
    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/BufferingHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java?view=diff&rev=544120&r1=544119&r2=544120
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java
Mon Jun  4 04:11:25 2007
@@ -230,6 +230,7 @@
                     HttpVersion.HTTP_1_0, HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
             HttpParamsLinker.link(response, this.params);
             handleException(httpex, response);
+            response.setEntity(null);
             sendResponse(conn, response);
             
         } catch (IOException ex) {

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=544120&r1=544119&r2=544120
==============================================================================
--- 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:11:25 2007
@@ -172,12 +172,41 @@
         }
     }
     
-    public void exception(final NHttpServerConnection conn, final HttpException ex) {
-        shutdownConnection(conn);
+    public void exception(final NHttpServerConnection conn, final HttpException httpex) {
+        HttpContext context = conn.getContext();
         
-        if (this.eventListener != null) {
-            this.eventListener.fatalProtocolException(ex, conn);
+        ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
+        
+        try {
+
+            HttpResponse response = this.responseFactory.newHttpResponse(
+                    HttpVersion.HTTP_1_0, 
+                    HttpStatus.SC_INTERNAL_SERVER_ERROR, 
+                    context);
+            HttpParamsLinker.link(response, this.params);
+            handleException(httpex, response);
+            response.setEntity(null);
+            
+            this.httpProcessor.process(response, context);
+            
+            synchronized (connState) {
+                connState.setResponse(response);
+                // Response is ready to be committed
+                conn.requestOutput();
+            }
+            
+        } catch (IOException ex) {
+            shutdownConnection(conn);
+            if (eventListener != null) {
+                eventListener.fatalIOException(ex, conn);
+            }
+        } catch (HttpException ex) {
+            shutdownConnection(conn);
+            if (eventListener != null) {
+                eventListener.fatalProtocolException(ex, conn);
+            }
         }
+
     }
 
     public void exception(final NHttpServerConnection conn, final IOException ex) {
@@ -278,11 +307,14 @@
         HttpContext context = conn.getContext();
 
         ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
-        HttpResponse response = connState.getResponse();
-        if (connState.getOutputState() == ServerConnState.READY 
-                && response != null 
-                && !conn.isResponseSubmitted()) {
-            try {
+
+        try {
+        
+            HttpResponse response = connState.getResponse();
+            if (connState.getOutputState() == ServerConnState.READY 
+                    && response != null 
+                    && !conn.isResponseSubmitted()) {
+
                 conn.submitResponse(response);
 
                 synchronized (connState) {
@@ -305,17 +337,17 @@
                     
                     connState.notifyAll();
                 }
-                
-            } catch (IOException ex) {
-                shutdownConnection(conn);
-                if (eventListener != null) {
-                    eventListener.fatalIOException(ex, conn);
-                }
-            } catch (HttpException ex) {
-                shutdownConnection(conn);
-                if (eventListener != null) {
-                    eventListener.fatalProtocolException(ex, conn);
-                }
+            }
+
+        } catch (IOException ex) {
+            shutdownConnection(conn);
+            if (eventListener != null) {
+                eventListener.fatalIOException(ex, conn);
+            }
+        } catch (HttpException ex) {
+            shutdownConnection(conn);
+            if (eventListener != null) {
+                eventListener.fatalProtocolException(ex, conn);
             }
         }
     }
@@ -504,7 +536,7 @@
             } catch (HttpException ex) {
                 response = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_0, 
                         HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
-                HttpParamsLinker.link(request, this.params);
+                HttpParamsLinker.link(response, this.params);
                 handleException(ex, response);
             }
         }



Mime
View raw message