Index: HttpMethodBase.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v retrieving revision 1.189 diff -u -r1.189 HttpMethodBase.java --- HttpMethodBase.java 5 Nov 2003 20:45:34 -0000 1.189 +++ HttpMethodBase.java 10 Nov 2003 12:51:43 -0000 @@ -1831,14 +1831,26 @@ throws IOException, HttpRecoverableException, HttpException { LOG.trace("enter HttpMethodBase.readStatusLine(HttpState, HttpConnection)"); + final int maxLinesToInspect = 5; // only inspect the first five lines + //read out the HTTP status string - String s = conn.readLine(); - while ((s != null) && !StatusLine.startsWithHTTP(s)) { - if (Wire.enabled()) { - Wire.input(s + "\r\n"); - } + int attempts = 0; + String s; + do { s = conn.readLine(); - } + if(s != null) { + if (Wire.enabled()) { + Wire.input(s + "\r\n"); + } + + if(StatusLine.startsWithHTTP(s)) { + break; + } else { + s = null; + } + } + } while(attempts++ < maxLinesToInspect); + if (s == null) { // A null statusString means the connection was lost before we got a // response. Try again. @@ -1846,9 +1858,7 @@ + " line from the response: unable to find line starting with" + " \"HTTP\""); } - if (Wire.enabled()) { - Wire.input(s + "\r\n"); - } + //create the status line from the status string statusLine = new StatusLine(s);