hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r917747 - in /httpcomponents/httpcore/trunk: RELEASE_NOTES.txt httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java
Date Mon, 01 Mar 2010 22:04:25 GMT
Author: olegk
Date: Mon Mar  1 22:04:24 2010
New Revision: 917747

URL: http://svn.apache.org/viewvc?rev=917747&view=rev
Log:
HTTPCORE-218: ChunkEncoder#write method no longer returns incorrect value if the data to write
is greater than the size of the internal buffer used by the encoder
Contributed by Richie Jefts <rjefts at gmail.com>

Modified:
    httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java

Modified: httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=917747&r1=917746&r2=917747&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Mon Mar  1 22:04:24 2010
@@ -1,5 +1,9 @@
 Changes since 4.1-ALPHA1
 
+* [HTTPCORE-218] ChunkEncoder#write method no longer returns incorrect value if 
+  the data to write is greater than the size of the internal buffer used by the encoder.
+  Contributed by Richie Jefts <rjefts at gmail.com> 
+
 * [HTTPCORE-209] Added parameter to set SO_REUSEADDR on sockets bound to a local address.
   Contributed by Oleg Kalnichevski <olegk at apache.org> 
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java?rev=917747&r1=917746&r2=917747&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java
Mon Mar  1 22:04:24 2010
@@ -91,11 +91,12 @@
 
         if (avail < chunk) {
             // write no more than 'avail' bytes
+            chunk = avail;
             this.lineBuffer.clear();
-            this.lineBuffer.append(Integer.toHexString(avail));
+            this.lineBuffer.append(Integer.toHexString(chunk));
             this.buffer.writeLine(this.lineBuffer);
             int oldlimit = src.limit();
-            src.limit(src.position() + avail);
+            src.limit(src.position() + chunk);
             this.buffer.write(src);
             src.limit(oldlimit);
         } else {

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java?rev=917747&r1=917746&r2=917747&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestChunkEncoder.java
Mon Mar  1 22:04:24 2010
@@ -126,15 +126,15 @@
         
         ByteBuffer src = wrap("0123456789ABCDEF");
         
-        encoder.write(src);
+        assertEquals(6, encoder.write(src));
         assertTrue(src.hasRemaining());
         assertEquals(10, src.remaining());
 
-        encoder.write(src);
+        assertEquals(6, encoder.write(src));
         assertTrue(src.hasRemaining());
         assertEquals(4, src.remaining());
 
-        encoder.write(src);
+        assertEquals(4, encoder.write(src));
         assertFalse(src.hasRemaining());
         
         outbuf.flush(channel);



Mime
View raw message