hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r507555 - in /jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio: protocol/ContentOutputStream.java util/ContentOutputBuffer.java util/SharedOutputBuffer.java util/SimpleOutputBuffer.java
Date Wed, 14 Feb 2007 14:54:35 GMT
Author: olegk
Date: Wed Feb 14 06:54:34 2007
New Revision: 507555

URL: http://svn.apache.org/viewvc?view=rev&rev=507555
Log:
Fixed bug in the ContentOutputStream preventing chunk-encoded streams from being correctly
terminated

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentOutputStream.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/ContentOutputBuffer.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentOutputStream.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentOutputStream.java?view=diff&rev=507555&r1=507554&r2=507555
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentOutputStream.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ContentOutputStream.java
Wed Feb 14 06:54:34 2007
@@ -49,6 +49,7 @@
     }
 
     public void close() throws IOException {
+        this.buffer.writeCompleted();
         this.buffer.flush();
     }
 

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/ContentOutputBuffer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/ContentOutputBuffer.java?view=diff&rev=507555&r1=507554&r2=507555
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/ContentOutputBuffer.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/ContentOutputBuffer.java
Wed Feb 14 06:54:34 2007
@@ -49,4 +49,6 @@
 
     void write(int b) throws IOException;
     
+    void writeCompleted() throws IOException;
+    
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java?view=diff&rev=507555&r1=507554&r2=507555
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
Wed Feb 14 06:54:34 2007
@@ -69,12 +69,19 @@
         synchronized (this.mutex) {
             setOutputMode();
             int bytesWritten = encoder.write(this.buffer);
+            if (encoder.isCompleted()) {
+                this.endOfStream = true;
+            }
             if (!hasData()) {
-                if (this.endOfStream) {
+                // No more buffered content
+                // If at the end of the stream
+                if (this.endOfStream && !encoder.isCompleted()) {
                     encoder.complete();
+                } else {
+                    // suspend output events
+                    this.ioctrl.suspendOutput();
+                    this.mutex.notifyAll();            
                 }
-                this.ioctrl.suspendOutput();
-                this.mutex.notifyAll();            
             }
             return bytesWritten;
         }
@@ -108,9 +115,6 @@
         if (b == null) {
             return;
         }
-        if (this.shutdown || this.endOfStream) {
-            return;
-        }
         synchronized (this.mutex) {
             setInputMode();
             int remaining = len;
@@ -135,9 +139,6 @@
     }
 
     public void write(int b) throws IOException {
-        if (this.shutdown || this.endOfStream) {
-            return;
-        }
         synchronized (this.mutex) {
             setInputMode();
             if (!this.buffer.hasRemaining()) {
@@ -152,9 +153,9 @@
         flushBuffer();
     }
     
-    public void close() throws IOException {
+    public void writeCompleted() throws IOException {
         this.endOfStream = true;
-        flushBuffer();
+        this.ioctrl.requestOutput();
     }
     
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java?view=diff&rev=507555&r1=507554&r2=507555
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java
Wed Feb 14 06:54:34 2007
@@ -91,6 +91,10 @@
     public void flush() {
     }
 
+    public void writeCompleted() {
+        this.endOfStream = true;
+    }
+    
     public void shutdown() {
         this.endOfStream = true;
     }



Mime
View raw message