commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alv...@dsl.ab.ca
Subject [PATCH] HttpClient ResponseInputStream.read() detecting EOF
Date Tue, 19 Feb 2002 23:34:54 GMT
Hi,

  I tried sub-classing PostMethod and over-riding the readResponseBody
method.  The input stream read() method does not detect the 'end of
file' condition, and eventually runs past the end of the input buffer.

a possible patch is:

--- src/java/org/apache/commons/httpclient/ResponseInputStream.java     Tue Feb 19 16:28:54
2002
+++ ResponseInputStream.java    Tue Feb 19 16:25:51 2002
@@ -378,6 +378,8 @@
                 if (buffer == null)
                     buffer = new byte[4096];
                 length = stream.read(buffer);
+                if (length == -1)
+                    return false;
                 count += length;
             } catch (Throwable t) {
                 t.printStackTrace();



Comments, suggestions welcome.


Alvin.

PS: I am not subscribed commons-dev@jakarta.apache.org

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message