hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1234754 - in /httpcomponents/httpcore/trunk/httpcore-nio/src: main/java/org/apache/http/impl/nio/ main/java/org/apache/http/nio/ main/java/org/apache/http/nio/protocol/ test/java/org/apache/http/testserver/
Date Mon, 23 Jan 2012 11:45:49 GMT
Author: olegk
Date: Mon Jan 23 11:45:48 2012
New Revision: 1234754

URL: http://svn.apache.org/viewvc?rev=1234754&view=rev
Log:
Support for half-closed HTTP connections

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpClientEventHandlerAdaptor.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpServerEventHandlerAdaptor.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/NHttpClientEventHandler.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/NHttpServerEventHandler.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpClientEventHandlerAdaptor.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpServerEventHandlerAdaptor.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java?rev=1234754&r1=1234753&r2=1234754&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
Mon Jan 23 11:45:48 2012
@@ -170,7 +170,7 @@ public class DefaultNHttpClientConnectio
                     }
                 }
                 if (bytesRead == -1) {
-                    close();
+                    handler.endOfInput(this);
                 }
             }
             if (this.contentDecoder != null && (this.session.getEventMask() &
SelectionKey.OP_READ) > 0) {

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java?rev=1234754&r1=1234753&r2=1234754&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
Mon Jan 23 11:45:48 2012
@@ -171,7 +171,7 @@ public class DefaultNHttpServerConnectio
                     }
                 }
                 if (bytesRead == -1) {
-                    close();
+                    handler.endOfInput(this);
                 }
             }
             if (this.contentDecoder != null && (this.session.getEventMask() &
SelectionKey.OP_READ) > 0) {

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpClientEventHandlerAdaptor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpClientEventHandlerAdaptor.java?rev=1234754&r1=1234753&r2=1234754&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpClientEventHandlerAdaptor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpClientEventHandlerAdaptor.java
Mon Jan 23 11:45:48 2012
@@ -86,6 +86,10 @@ class NHttpClientEventHandlerAdaptor imp
         }
     }
 
+    public void endOfInput(final NHttpClientConnection conn) throws IOException {
+        conn.close();
+    }
+
     public void timeout(final NHttpClientConnection conn) {
         this.handler.timeout(conn);
     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpServerEventHandlerAdaptor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpServerEventHandlerAdaptor.java?rev=1234754&r1=1234753&r2=1234754&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpServerEventHandlerAdaptor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpServerEventHandlerAdaptor.java
Mon Jan 23 11:45:48 2012
@@ -86,6 +86,10 @@ class NHttpServerEventHandlerAdaptor imp
         }
     }
 
+    public void endOfInput(final NHttpServerConnection conn) throws IOException {
+        conn.close();
+    }
+
     public void timeout(final NHttpServerConnection conn) {
         this.handler.timeout(conn);
     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/NHttpClientEventHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/NHttpClientEventHandler.java?rev=1234754&r1=1234753&r2=1234754&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/NHttpClientEventHandler.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/NHttpClientEventHandler.java
Mon Jan 23 11:45:48 2012
@@ -119,6 +119,15 @@ public interface NHttpClientEventHandler
             ContentEncoder encoder) throws IOException, HttpException;
 
     /**
+     * Triggered when the connection is closed by the opposite end point
+     * (half-closed).
+     *
+     * @param conn half-closed HTTP connection.
+     */
+    void endOfInput(
+            NHttpClientConnection conn) throws IOException;
+
+    /**
      * Triggered when no input is detected on this connection over the
      * maximum period of inactivity.
      *

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/NHttpServerEventHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/NHttpServerEventHandler.java?rev=1234754&r1=1234753&r2=1234754&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/NHttpServerEventHandler.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/NHttpServerEventHandler.java
Mon Jan 23 11:45:48 2012
@@ -118,6 +118,15 @@ public interface NHttpServerEventHandler
             ContentEncoder encoder) throws IOException, HttpException;
 
     /**
+     * Triggered when the connection is closed by the opposite end point
+     * (half-closed).
+     *
+     * @param conn half-closed HTTP connection.
+     */
+    void endOfInput(
+            NHttpServerConnection conn) throws IOException;
+
+    /**
      * Triggered when no input is detected on this connection over the
      * maximum period of inactivity.
      *

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java?rev=1234754&r1=1234753&r2=1234754&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
Mon Jan 23 11:45:48 2012
@@ -265,6 +265,10 @@ public class HttpAsyncRequestExecutor im
         }
     }
 
+    public void endOfInput(final NHttpClientConnection conn) throws IOException {
+        conn.close();
+    }
+
     public void timeout(
             final NHttpClientConnection conn) throws IOException {
         State state = getState(conn);

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java?rev=1234754&r1=1234753&r2=1234754&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
Mon Jan 23 11:45:48 2012
@@ -367,6 +367,10 @@ public class HttpAsyncService implements
         }
     }
 
+    public void endOfInput(final NHttpServerConnection conn) throws IOException {
+        conn.close();
+    }
+
     public void timeout(final NHttpServerConnection conn) throws IOException {
         State state = getState(conn);
         if (state != null) {

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpClientEventHandlerAdaptor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpClientEventHandlerAdaptor.java?rev=1234754&r1=1234753&r2=1234754&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpClientEventHandlerAdaptor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpClientEventHandlerAdaptor.java
Mon Jan 23 11:45:48 2012
@@ -86,6 +86,10 @@ class NHttpClientEventHandlerAdaptor imp
         }
     }
 
+    public void endOfInput(final NHttpClientConnection conn) throws IOException {
+        conn.close();
+    }
+
     public void timeout(final NHttpClientConnection conn) {
         this.handler.timeout(conn);
     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpServerEventHandlerAdaptor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpServerEventHandlerAdaptor.java?rev=1234754&r1=1234753&r2=1234754&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpServerEventHandlerAdaptor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/testserver/NHttpServerEventHandlerAdaptor.java
Mon Jan 23 11:45:48 2012
@@ -86,6 +86,10 @@ class NHttpServerEventHandlerAdaptor imp
         }
     }
 
+    public void endOfInput(final NHttpServerConnection conn) throws IOException {
+        conn.close();
+    }
+
     public void timeout(final NHttpServerConnection conn) {
         this.handler.timeout(conn);
     }



Mime
View raw message