hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r159033 - jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataTransmitter.java
Date Fri, 25 Mar 2005 16:19:16 GMT
Author: olegk
Date: Fri Mar 25 08:19:15 2005
New Revision: 159033

URL: http://svn.apache.org/viewcvs?view=rev&rev=159033
Log:
Fixed broken write(byte[], int, int) method

Modified:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataTransmitter.java

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataTransmitter.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataTransmitter.java?view=diff&r1=159032&r2=159033
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataTransmitter.java
(original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataTransmitter.java
Fri Mar 25 08:19:15 2005
@@ -120,15 +120,19 @@
         if (b == null) {
             return;
         }
-        int i = off;
-        while (i < len) {
+        int remaining = len;
+        while (remaining > 0) {
             if (this.buffer.hasRemaining()) {
-                int chunk = len - i;
+                int chunk = len;
+                if (chunk > remaining) {
+                    chunk = remaining;
+                }
                 if (chunk > this.buffer.remaining()) {
                     chunk = this.buffer.remaining();
                 }
-                this.buffer.put(b, i, chunk);
-                i += chunk;
+                this.buffer.put(b, off, chunk);
+                off += chunk;
+                remaining -= chunk; 
             } else {
                 flushBuffer();
             }



Mime
View raw message