netty/netty — Issue #222: HttpMessageDecoder fails on Hixie76
Author: normanmaurer
Created: 2012-03-07 17:15:03+00:00
State: open

Tim Fox wrote:

Something I completely forgot about:

When I was running using Netty 3.4.0.alpha one of my websockets tests started failing, and I remembered that there was one other small change I had made to my hacked version of 3.2.5.final, this is not related to the changes I made for event loops.

Basically... HttpMessageDecoder:

protected boolean isContentAlwaysEmpty(HttpMessage msg) {
if (msg instanceof HttpResponse) {
HttpResponse res = (HttpResponse) msg;
int code = res.getStatus().getCode();
if (code < 200) {
return true;
}
switch (code) {
case 204: case 205: case 304:
return true;
}
}
return false;
}

The problem with this is it always returns true if code < 200. But for earlier versions (Hixie76) of websockets the return code is 101 (Response to a websockets upgrade), but the content is not empty in this case.

This causes Hixie76 handshakes to fail if Netty is used on the client side.

The fix is trivial, I just changed it to:

if (code < 200 && code != 101) {

Which seems to work fine.

Apologies, I should have reported this ages ago when I first found it!