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 2005/09/11 13:39:49 UTC

svn commit: r280106 - /jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/InputStreamHttpDataReceiver.java

Author: olegk
Date: Sun Sep 11 04:39:45 2005
New Revision: 280106

URL: http://svn.apache.org/viewcvs?rev=280106&view=rev
Log:
Fixed a rather nasty bug in the input buffering code

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

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/InputStreamHttpDataReceiver.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/InputStreamHttpDataReceiver.java?rev=280106&r1=280105&r2=280106&view=diff
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/InputStreamHttpDataReceiver.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/io/InputStreamHttpDataReceiver.java Sun Sep 11 04:39:45 2005
@@ -86,17 +86,14 @@
     	}
     	int l;
     	int off = this.bufferlen;
-    	int len = this.buffer.length - this.bufferlen;
-    	while ((l = this.instream.read(this.buffer, off, len)) > 0) {
-    		off += l;
-            len -= l;
+    	int len = this.buffer.length - off;
+    	l = this.instream.read(this.buffer, off, len);
+    	if (l == -1) {
+    		return -1;
+    	} else {
+        	this.bufferlen = off + l;
+        	return l;
     	}
-    	this.bufferlen = off;
-        if (l == -1 && off == 0) {
-            return -1;
-        } else {
-            return off;
-        }
     }
 
     protected boolean hasBufferedData() {