hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r500533 - in /jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio: impl/ protocol/
Date Sat, 27 Jan 2007 14:10:56 GMT
Author: olegk
Date: Sat Jan 27 06:10:55 2007
New Revision: 500533

URL: http://svn.apache.org/viewvc?view=rev&rev=500533
Log:
Fixed the problem that caused the closing chunk to not be written when the output stream is
not set to 'end of stream' mode

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/OutputBuffer.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.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/main/java/org/apache/http/nio/impl/OutputBuffer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/OutputBuffer.java?view=diff&rev=500533&r1=500532&r2=500533
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/OutputBuffer.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/OutputBuffer.java
Sat Jan 27 06:10:55 2007
@@ -36,19 +36,28 @@
 
 public class OutputBuffer extends ExpandableBuffer implements ContentOutputBuffer {
     
+    private boolean endOfStream;
+    
     public OutputBuffer(int buffersize) {
         super(buffersize);
+        this.endOfStream = false;
     }
 
     public void produceContent(final ContentEncoder encoder) throws IOException {
         setOutputMode();
         encoder.write(this.buffer);
+        if (!hasData() && this.endOfStream) {
+            encoder.complete();
+        }
     }
     
     public void write(final byte[] b, int off, int len) throws IOException {
         if (b == null) {
             return;
         }
+        if (this.endOfStream) {
+            return;
+        }
         setInputMode();
         ensureCapacity(this.buffer.position() + len);
         this.buffer.put(b, off, len);
@@ -58,23 +67,31 @@
         if (b == null) {
             return;
         }
+        if (this.endOfStream) {
+            return;
+        }
         write(b, 0, b.length);
     }
 
     public void write(int b) throws IOException {
+        if (this.endOfStream) {
+            return;
+        }
         setInputMode();
         ensureCapacity(this.capacity() + 1);
         this.buffer.put((byte)b);
     }
     
     public void clear() {
-        super.clear();        
+        super.clear();
+        this.endOfStream = false;
     }
     
     public void flush() {
     }
 
     public void shutdown() {
+        this.endOfStream = true;
     }
     
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java?view=diff&rev=500533&r1=500532&r2=500533
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
Sat Jan 27 06:10:55 2007
@@ -323,6 +323,7 @@
                 OutputStream outstream = new ContentOutputStream(outbuffer);
                 entity.writeTo(outstream);
                 outstream.flush();
+                outstream.close();
             }
         }
         

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=500533&r1=500532&r2=500533
==============================================================================
--- 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
Sat Jan 27 06:10:55 2007
@@ -371,6 +371,7 @@
                 OutputStream outstream = new ContentOutputStream(outbuffer);
                 entity.writeTo(outstream);
                 outstream.flush();
+                outstream.close();
             }
         }
     }

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=500533&r1=500532&r2=500533
==============================================================================
--- 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
Sat Jan 27 06:10:55 2007
@@ -419,6 +419,7 @@
             OutputStream outstream = new ContentOutputStream(outbuffer);
             entity.writeTo(outstream);
             outstream.flush();
+            outstream.close();
         }
     }
     



Mime
View raw message