hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r594529 - in /jakarta/httpcomponents/httpcore/trunk/module-nio/src: examples/org/apache/http/examples/nio/ main/java/org/apache/http/impl/nio/ main/java/org/apache/http/nio/protocol/
Date Tue, 13 Nov 2007 13:25:03 GMT
Author: olegk
Date: Tue Nov 13 05:25:02 2007
New Revision: 594529

URL: http://svn.apache.org/viewvc?rev=594529&view=rev
Log:
Better handling of non-fatal protocol exceptions 

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpFileServer.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
    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/examples/org/apache/http/examples/nio/NHttpFileServer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpFileServer.java?rev=594529&r1=594528&r2=594529&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpFileServer.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/examples/nio/NHttpFileServer.java
Tue Nov 13 05:25:02 2007
@@ -240,6 +240,11 @@
         }
 
         public void exception(final NHttpServerConnection conn, final HttpException ex) {
+            if (conn.isResponseSubmitted()) {
+                System.err.println("Unexpected HTTP protocol error: " + ex.getMessage());
+                return;
+            }
+            
             HttpContext context = conn.getContext();
             HttpResponse response =  this.responseFactory.newHttpResponse(
                     HttpVersion.HTTP_1_0, HttpStatus.SC_BAD_REQUEST, context);

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java?rev=594529&r1=594528&r2=594529&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
Tue Nov 13 05:25:02 2007
@@ -142,6 +142,7 @@
         } catch (IOException ex) {
             handler.exception(this, ex);
         } catch (HttpException ex) {
+            resetInput();
             handler.exception(this, ex);
         } finally {
             // Finally set buffered input flag

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java?rev=594529&r1=594528&r2=594529&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
Tue Nov 13 05:25:02 2007
@@ -142,6 +142,7 @@
         } catch (IOException ex) {
             handler.exception(this, ex);
         } catch (HttpException ex) {
+            resetInput();
             handler.exception(this, ex);
         } finally {
             // Finally set buffered input flag

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?rev=594529&r1=594528&r2=594529&view=diff
==============================================================================
--- 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
Tue Nov 13 05:25:02 2007
@@ -193,6 +193,13 @@
     }
 
     public void exception(final NHttpServerConnection conn, final HttpException httpex) {
+        if (conn.isResponseSubmitted()) {
+            if (eventListener != null) {
+                eventListener.fatalProtocolException(httpex, conn);
+            }
+            return;
+        }
+        
         HttpContext context = conn.getContext();
         try {
             HttpResponse response = this.responseFactory.newHttpResponse(

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?rev=594529&r1=594528&r2=594529&view=diff
==============================================================================
--- 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
Tue Nov 13 05:25:02 2007
@@ -133,6 +133,13 @@
     }
     
     public void exception(final NHttpServerConnection conn, final HttpException httpex) {
+        if (conn.isResponseSubmitted()) {
+            if (eventListener != null) {
+                eventListener.fatalProtocolException(httpex, conn);
+            }
+            return;
+        }
+        
         HttpContext context = conn.getContext();
         
         ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);



Mime
View raw message