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/03/25 17:20:46 UTC
svn commit: r159034 -
jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataReceiver.java
Author: olegk
Date: Fri Mar 25 08:20:46 2005
New Revision: 159034
URL: http://svn.apache.org/viewcvs?view=rev&rev=159034
Log:
Fixed the problem with not prefilling the input buffer in read(final byte[], int, int) method
Modified:
jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataReceiver.java
Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataReceiver.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataReceiver.java?view=diff&r1=159033&r2=159034
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataReceiver.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/NIOHttpDataReceiver.java Fri Mar 25 08:20:46 2005
@@ -96,11 +96,20 @@
if (b == null) {
return 0;
}
+ int noRead = 0;
+ // prefill the buffer if necessary
+ if (this.buffer.position() == 0) {
+ noRead = fillBuffer();
+ if (noRead == -1) {
+ // end of stream
+ return -1;
+ }
+ }
if (!this.buffer.hasRemaining()) {
this.buffer.clear();
- int noRead = fillBuffer();
+ noRead = fillBuffer();
if (noRead == -1) {
- return noRead;
+ return -1;
}
}
int chunk = len;