You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by "Pill, Juergen" <Ju...@softwareag.com> on 2001/07/16 11:26:55 UTC
HttpClient and Tomcat 3.3
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);
}
Re: HttpClient and Tomcat 3.3
Posted by Remy Maucherat <re...@apache.org>.
> 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).
Yes, I'll put the patch in. You should have karma on Commons (since you're
in the committers list for ), though, so if you don't you can complain to
the root.
> 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?
At least in HTTP/1.1, it doesn't appear to be legal (but we should fix the
nasty exception which occurs, and politely ignore).
#6.1 :
Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
Remy