Index: org/apache/commons/httpclient/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 --- org/apache/commons/httpclient/HttpMethodBase.java 5 Nov 2003 20:45:34 -0000 1.189 +++ org/apache/commons/httpclient/HttpMethodBase.java 11 Nov 2003 09:45:07 -0000 @@ -1831,14 +1831,26 @@ throws IOException, HttpRecoverableException, HttpException { LOG.trace("enter HttpMethodBase.readStatusLine(HttpState, HttpConnection)"); + final int maxGarbageLines = getParams().getIntParameter(HttpMethodParams.STATUS_LINE_GARBAGE_LIMIT, Integer.MAX_VALUE); + //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++ < maxGarbageLines); + 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); Index: org/apache/commons/httpclient/params/HttpMethodParams.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java,v retrieving revision 1.5 diff -u -r1.5 HttpMethodParams.java --- org/apache/commons/httpclient/params/HttpMethodParams.java 22 Oct 2003 19:31:00 -0000 1.5 +++ org/apache/commons/httpclient/params/HttpMethodParams.java 11 Nov 2003 09:45:07 -0000 @@ -184,7 +184,25 @@ * This parameter expects a value of type {@link String}. *
*/ - public static final String COOKIE_POLICY = "http.protocol.cookie-policy"; + public static final String COOKIE_POLICY = "http.protocol.cookie-policy"; + + /** + * Defines the maximum number of ignorable lines before we expect + * a HTTP response's status code. + *+ * With HTTP/1.1 persistent connections, the problem arises that + * broken scripts could return a wrong Content-Length + * (there are more bytes sent than specified), and + * HttpClient must be able to skip those surplus lines. + *
+ *
+ * Set this to 0 to disallow any garbage lines before the status line.
+ * To specify no limit, use {@link Integer.MAX_VALUE}.
+ *