Hello,

I think I found another problem with HttpClient. If the server is returning
"HTTP/1.0 423"  without an readable response code the parseStatusLine method
fails. This is due to this line                 int to =
statusLine.indexOf(" ", at + 1);
which expects an additional blank, which is not supported by the server. I
suggest to modify the following if statement if following way:
(if I have access to CVS, I will perform this change, else: Remy would you
be so kind).

The reason is, that Tomcat 3.3 does not deliver the readable status text (at
least for locked) any more. Would this be a Tomcat bug?

        /**
         * Parse status line.
         *
         * @param statusLine String representing the HTTP status line
         * @param method Http method
         */
        protected void parseStatusLine(String statusLine, HttpMethod method)
                throws IOException, HttpException {

                while (statusLine != null &&
!statusLine.startsWith("HTTP/")) {
                        statusLine = readLine(input);
                }
                        
                if (debug > 0) {
                        System.out.println();
                        System.out.println(statusLine);
                }
                        
                if (statusLine == null)
                        throw new HttpException("Error in parsing the
response: " + statusLine);

                if ((!statusLine.startsWith("HTTP/1.1") &&
!statusLine.startsWith("HTTP/1.0")))
                        throw new HttpException("Incorrect server protocol :
" + statusLine);

                http11 = statusLine.startsWith("HTTP/1.1");

                int statusCode = -1;

                int at = statusLine.indexOf(" ");
                if (at < 0)
                        throw new HttpException("Status not specified: " +
statusLine);
                        
                int to = statusLine.indexOf(" ", at + 1);
                if (to < 0)
                        to = statusLine.length();
                        
                try {
                        statusCode =
Integer.parseInt(statusLine.substring(at+1, to));
                } catch (NumberFormatException e) {
                        throw new HttpException("Status not specified: " +
statusLine);
                }

                method.setStatusCode(statusCode);


                String statusText = null;
                try {
                        if (to < statusLine.length())
                                statusText = statusLine.substring(to + 1);
                } catch (StringIndexOutOfBoundsException e) {
                        throw new HttpException("Status not specified: " +
statusLine);
                }

                if (statusText != null)
                        method.setStatusText(statusText);
        }

Reply via email to