Index: java/org/apache/commons/httpclient/StatusLine.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/StatusLine.java,v retrieving revision 1.9.2.3 diff -u -r1.9.2.3 StatusLine.java --- java/org/apache/commons/httpclient/StatusLine.java 22 Feb 2004 18:21:13 -0000 1.9.2.3 +++ java/org/apache/commons/httpclient/StatusLine.java 19 Jul 2004 08:11:16 -0000 @@ -96,47 +96,39 @@ throw new HttpException("Status-Line '" + statusLine + "' does not start with HTTP"); } - } catch (StringIndexOutOfBoundsException e) { - throw new HttpException("Status-Line '" + statusLine + "' is not valid"); - } - //handle the HTTP-Version - at = statusLine.indexOf(" ", at); - if (at <= 0) { - throw new HttpException( - "Unable to parse HTTP-Version from the status line: '" + //handle the HTTP-Version + at = statusLine.indexOf(" ", at); + if (at <= 0) { + throw new HttpException( + "Unable to parse HTTP-Version from the status line: '" + + statusLine + "'"); + } + this.httpVersion = (statusLine.substring(start, at)).toUpperCase(); + //advance through spaces + while (statusLine.charAt(at) == ' ') { + at++; + } + //handle the Status-Code + int to = statusLine.indexOf(" ", at); + if (to < 0) { + to = length; + } + try { + this.statusCode = Integer.parseInt(statusLine.substring(at, to)); + } catch (NumberFormatException e) { + throw new HttpException( + "Unable to parse status code from status line: '" + statusLine + "'"); - } - this.httpVersion = (statusLine.substring(start, at)).toUpperCase(); - - //advance through spaces - while (statusLine.charAt(at) == ' ') { - at++; - } - - //handle the Status-Code - int to = statusLine.indexOf(" ", at); - if (to < 0) { - to = length; - } - try { - this.statusCode = Integer.parseInt(statusLine.substring(at, to)); - } catch (NumberFormatException e) { - throw new HttpException( - "Unable to parse status code from status line: '" - + statusLine + "'"); - } - - //handle the Reason-Phrase - at = to + 1; - try { + } + //handle the Reason-Phrase + at = to + 1; if (at < length) { this.reasonPhrase = statusLine.substring(at).trim(); } else { this.reasonPhrase = ""; } } catch (StringIndexOutOfBoundsException e) { - throw new HttpException("Status text not specified: '" - + statusLine + "'"); + throw new HttpException("Status-Line '" + statusLine + "' is not valid"); } //save the original Status-Line if everything is OK this.statusLine = new String(statusLine); Index: test/org/apache/commons/httpclient/TestStatusLine.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestStatusLine.java,v retrieving revision 1.6.2.2 diff -u -r1.6.2.2 TestStatusLine.java --- test/org/apache/commons/httpclient/TestStatusLine.java 22 Feb 2004 18:21:16 -0000 1.6.2.2 +++ test/org/apache/commons/httpclient/TestStatusLine.java 19 Jul 2004 08:11:16 -0000 @@ -139,6 +139,10 @@ fail(); } catch (HttpException e) { /* expected */ } + try { + statusLine = new StatusLine("HTTP/1.1 "); + fail(); + } catch (HttpException e) { /* expected */ } } }