Issue with netty websocket headers name in lowercase

123 views
Skip to first unread message

Subhadeep Sen

unread,
May 23, 2018, 1:51:04 AM5/23/18
to Netty discussions
Hello,
I am using netty to implement a websocket server. The server needs to work with some old websocket clients libraries (written in other languages) out there which does not honour the HTTP header case insensitivity rule.  I am facing a problem there.

My inbound channel pipeline is pretty standard which looks like following
HttpServerCodec -> HttpObjectAggregator -> HttpRequestBuilder ->WebSocketServerProtocolHandler -> WebSocketFrameAggregator -> CustomHandler

In netty version 4.1.23.Final I see that the websocket handshake response being sent to client is all in lowercase header names, like following.

upgrade: websocket\r\n
connection: upgrade\r\n
sec-websocket-accept: hex-values=\r\n

But the older websocket client expects the header in the following format.

Upgrade: websocket\r\n
Connection: Upgrade\r\n
Sec-WebSocket-Accept: hex-values=\r\n

As a result the websocket connection does not complete.
Has anybody faced this problem?

The header strings are coming from HttpHeaderNames class instead of HttpHeader class. The fix is to change WebSocketServerHandshaker13.newHandshakeResponse() to use the required HttpHeader. But that would need change in netty code itself probably .
Can somebody suggest any cleaner way to get around this problem without changing netty code?

1. Is there anyway to add/modify http  response header while using the existing netty websocket handshaker classes?
2. Should I write custom WebSocketServerProtocolHandler to achieve the same?
3. Any other way?

Appreciate any response!!!

Thanks much in advance.
Subhadeep
Reply all
Reply to author
Forward
0 new messages