hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Maloney <sam.malo...@filogix.com>
Subject [PATCH] Fix for bug 16458
Date Wed, 19 Feb 2003 22:23:34 GMT
Hi there,

As I am a new poster here, I will first describe myself and the situation. If 
you wish to skip this, skip down to after the line '-----'.

In a very large project I am a senior on, I use to be using HTTPClient v0.3-3 
(www.innovation.ch/java/HTTPClient/).

At the time I chose it, it was the superior client. However, because of the 
facts:

a) It does not work properly with sending the request as a stream without 
knowing the content length until stream.close(). (It claimed to work okay 
with this).

b) After looking at the code to try to fix the problem, not only did I give up 
trying to fix the problem, but I also gave up on the product :)

So anyways, hearing 2.0alpha of HttpClient was out, and supported both SSL 
(needed) and Streams (very good), I decided to try it out.

I want to point out that I encountered bug 13463 early on, and after reading 
the bugzilla db, I tried the patch attached to the end of it. I would just 
like to give my vote to include it into CVS, as it fixes the problem (bug 
13463) perfectly.

-----

As for bug 16458, I have fixed it.

It was a rather simple bug, and can be reproduced by closing the server side 
socket while the client is still waiting for a response. This will cause the 
client to take 100% cpu, and it will do so for ever and ever.

The fix is as follows (I have tested extensively any fixes I will post):

Index: HttpConnection.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v
retrieving revision 1.44
diff -u -r1.44 HttpConnection.java
--- HttpConnection.java	13 Feb 2003 21:31:53 -0000	1.44
+++ HttpConnection.java	19 Feb 2003 21:27:26 -0000
@@ -128,6 +128,10 @@
 
         StringBuffer buf = new StringBuffer();
         int ch = inputStream.read();
+        if(ch == -1){
+            // End Of File!
+            return null; // Let caller know!
+        }
         while (ch >= 0) {
             if (ch == '\r') {
                 ch = inputStream.read();

I have another bugfix that I will post in my next message.

Thanks,
Sam Maloney <me@sammaloney.com>

Mime
View raw message