You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2006/11/14 17:31:02 UTC

svn commit: r474857 - in /jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio: impl/DefaultNHttpServerConnection.java protocol/AsyncHttpService.java util/ContentInputBuffer.java

Author: olegk
Date: Tue Nov 14 08:31:01 2006
New Revision: 474857

URL: http://svn.apache.org/viewvc?view=rev&rev=474857
Log:
Some more bugs fixes

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/DefaultNHttpServerConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncHttpService.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/ContentInputBuffer.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/DefaultNHttpServerConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/DefaultNHttpServerConnection.java?view=diff&rev=474857&r1=474856&r2=474857
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/DefaultNHttpServerConnection.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/DefaultNHttpServerConnection.java Tue Nov 14 08:31:01 2006
@@ -87,12 +87,13 @@
                 int bytesRead = this.requestParser.fillBuffer(this.session.channel());
                 this.request = (HttpRequest) this.requestParser.parse(); 
                 if (this.request != null) {
-                    handler.requestReceived(this);
                     if (this.request instanceof HttpEntityEnclosingRequest) {
                         // Receive incoming entity
                         HttpEntity entity = prepareDecoder(this.request);
                         ((HttpEntityEnclosingRequest)this.request).setEntity(entity);
-                    } else {
+                    }
+                    handler.requestReceived(this);
+                    if (this.contentDecoder == null) {
                         // No request entity is expected
                         // Ready to receive a new request
                         resetInput();

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncHttpService.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncHttpService.java?view=diff&rev=474857&r1=474856&r2=474857
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncHttpService.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/AsyncHttpService.java Tue Nov 14 08:31:01 2006
@@ -106,9 +106,6 @@
     
     public void handleRequest(final HttpRequest request, final NHttpServerConnection conn) 
                 throws HttpException, IOException {
-        // Reset buffers
-        this.inbuffer.reset();
-        this.outbuffer.reset();
         HttpContext parentContext = conn.getContext();
         HttpVersion ver = request.getRequestLine().getHttpVersion();
         if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
@@ -177,16 +174,16 @@
         }
 
         // Test if the connection can be reused
-        if (!this.connStrategy.keepAlive(response, context)) {
+        if (this.connStrategy.keepAlive(response, context)) {
+            this.inbuffer.reset();
+            this.outbuffer.reset();
+        } else {
             conn.close();
         }
     }
     
     public void handleException(final NHttpServerConnection conn, final HttpException ex)
                 throws HttpException, IOException {
-        // Reset buffers
-        this.inbuffer.reset();
-        this.outbuffer.reset();
         // Generate response
         HttpContext context = conn.getContext();
         HttpResponse response = this.responseFactory.newHttpResponse(
@@ -216,10 +213,12 @@
         outstream.flush();
 
         // Test if the connection can be reused
-        if (!this.connStrategy.keepAlive(response, context)) {
+        if (this.connStrategy.keepAlive(response, context)) {
+            this.inbuffer.reset();
+            this.outbuffer.reset();
+        } else {
             conn.close();
         }
-    
     }
     
     public void consumeContent(final ContentDecoder decoder) throws IOException {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/ContentInputBuffer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/ContentInputBuffer.java?view=diff&rev=474857&r1=474856&r2=474857
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/ContentInputBuffer.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/ContentInputBuffer.java Tue Nov 14 08:31:01 2006
@@ -73,8 +73,8 @@
             }
             if (bytesRead > 0) {
                 this.ioctrl.suspendInput();
-                this.mutex.notifyAll();            
             }
+            this.mutex.notifyAll();            
         }
     }