extend/cowboy — Issue #73: Various WebSocket improvements
Author: majek
Created: 2011-10-18 14:42:16+00:00
State: open

1) In order to get Hixie76 through a HAProxy loadbalancer the server must send response headers before the request nonce is received. In other words: before haproxy will send extra data from the client it expects the server to respond to the header. Current cowboy implementation does not support that. Example (`nc localhost 8080` and paste):

```
GET /echo/000/afc7f9ea-5b6f-4c94-bc2e-4fe7f5a74241/websocket HTTP/1.1
Host: localhost:8080
Accept-Encoding: identity
Origin: http://localhost:8080
Connection: Upgrade
Upgrade: WebSocket
Sec-WebSocket-Key2: 12998 5 Y3 1 .P00
Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5

```
Result: cowboy waits.
Expected result: response headers.
How to trigger expected result: type eight more bytes and press enter.

2) For hybi10 the `Upgrade` header should be checked case-insensitive.

```
GET /echo/000/0915ea93-b956-4dfe-bb0a-16f073df0cfc/websocket HTTP/1.1
Host: localhost:8080
Accept-Encoding: identity
Sec-WebSocket-Version: 8
Connection: Upgrade
Upgrade: WebSocket
Sec-WebSocket-Origin: http://pmx
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
```

Result: 400 Bad Request.
Expected result: should work
How to trigger expected result: change `WebSocket` to `websocket`

3) Cowboy should not set `content-length` for websockets.

```
GET /echo/000/f2257c26-4889-409a-92ed-ef470750b93a/websocket HTTP/1.1
Host: localhost:8080
Accept-Encoding: identity
Sec-WebSocket-Version: 7
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Origin: http://pmx
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==

HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Content-Length: 0
Date: Tue, 18 Oct 2011 14:39:20 GMT
Sec-Websocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
Server: Cowboy
Upgrade: websocket
```

Result: Content-length header present
Expected result: no content-length header