Fixed a bug where non-successful HEAD response is assumed to have a message body

This commit is contained in:
Trustin Lee 2010-04-16 06:40:29 +00:00
parent 640fae7963
commit d38219a85c

View File

@ -120,11 +120,16 @@ public class HttpClientCodec implements ChannelUpstreamHandler,
// current response.
HttpMethod method = queue.poll();
// Successful HEAD and CONNECT result in empty body.
// According to 4.3, RFC2616:
// All responses to the HEAD request method MUST NOT include a
// message-body, even though the presence of entity-header fields
// might lead one to believe they do.
if (HttpMethod.HEAD.equals(method)) {
return true;
}
// Successful CONNECT result in empty body.
if (((HttpResponse) msg).getStatus().getCode() == 200) {
if (HttpMethod.HEAD.equals(method)) {
return true;
}
if (HttpMethod.CONNECT.equals(method)) {
// Proxy connection established - Not HTTP anymore.
done = true;