netty/netty

WebSocketClientHandshakeException does not return content

snehanie opened this issue · 1 comments

Expected behavior

According to RFC 6455, when response is non 101 it has to be treated like normal http response.

Stating the RFC here:

If the status code received from the server is not 101, the
client handles the response per HTTP [RFC2616] procedures. In
particular, the client might perform authentication if it
receives a 401 status code; the server might redirect the client
using a 3xx status code (but clients are not required to follow
them), etc. Otherwise, proceed as follows.

Actual behavior

WebSocketClientHandshakeException discards content by holding the response in DefaultHttpResponse instead of DefaultFullHttpResponse. I see the comment about this in the class, but it does not say why content is not present. What is the reason for not returning the content? According to RFC 6455, when response is non 101 it has to be treated like normal http response.

I see comment stating to avoid reference counting problems.
"""
Provide new WebSocketClientHandshakeException with HttpResponse field and WebSocketServerHandshakeException with HttpRequest field both of them without content for avoid reference counting
problems.
"""

But it is not following the rfc. Is it possible to fix this limitation?

Steps to reproduce

Mentioned above

Minimal yet complete reproducer code (or URL to code)

Netty version

4.1.110

JVM version (e.g. java -version)

NA

OS version (e.g. uname -a)

NA

Yeah this is by design as otherwise we might see leaks. That said maybe we could over a method that users could override to intercept the failure