You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Antony Mayi <an...@yahoo.com> on 2014/04/10 23:32:17 UTC

[users@httpd] websockets and chunked encoding

Hi,

Not sure which part to blame - whether Apache, mod_passenger or a browser - but my websocket handshake gets corrupted by apache sending it using chunked encoding.

Following is the response header that indicates switching to websocket:

HTTP/1.1 101 Switching Protocols
Date: Thu, 10 Apr 2014 15:21:28 GMT
Server: Apache/2.2.15 (CentOS)
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: S7wgnmtVSahQDCifkYwFlQajWcI=
X-Powered-By: Phusion Passenger 4.0.41
Status: 101 Switching Protocols
Transfer-Encoding: chunked
Content-Type: text/plain; charset=UTF-8

5
..1::

The problem is that right after that the server sends actual websocket frame but apache encodes it using chunked encoding (prepends it with chunk length - the number 5 in my example). Since the first byte of websocket frame is supposed to be frame opcode the chunk length is taken by browser (tested with Chrome) as this opcode and whole websocket is corrupted.

What's wrong? Is this apache's fault? I can see other webservers are not using chunked encoding when connection gets upgraded to websocket...

Thanks, Antony.