Skip to content

Instantly share code, notes, and snippets.

@imanel
Created June 1, 2011 10:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save imanel/1002083 to your computer and use it in GitHub Desktop.
Save imanel/1002083 to your computer and use it in GitHub Desktop.
EM-WebSocket: differences from specification

Handshake

Sent data:

GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 5

Expected response:

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Sec-WebSocket-Nonce: AQIDBAUGBwgJCgsMDQ4PEC==
Sec-WebSocket-Protocol: chat

Actual response:

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=

Diff:

-Sec-WebSocket-Nonce: AQIDBAUGBwgJCgsMDQ4PEC==
-Sec-WebSocket-Protocol: chat

Messages

When I try to send message to server then I push following string(from example)

0x84 0x05 0x48 0x65 0x6c 0x6c 0x6f

and message is not recognized. When I push message from em-websocket spec then everything is working.

Handshake

Sent data:

GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 6

Expected response:

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Sec-WebSocket-Protocol: chat

Actual response:

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=

Diff:

-Sec-WebSocket-Protocol: chat

Messages

When I try to send message to server then I push following string(from example)

0x84 0x05 0x48 0x65 0x6c 0x6c 0x6f

and message is not recognized. When I push message from em-websocket spec then everything is working.

Handshake

Sent data:

GET /demo HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: example.com
Origin: http://example.com
WebSocket-Protocol: sample

Expected response:

HTTP/1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
WebSocket-Origin: http://example.com
WebSocket-Location: ws://example.com/demo
WebSocket-Protocol: sample

Actual response:

HTTP/1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
WebSocket-Origin: http://example.com
WebSocket-Location: ws://example.com/demo
WebSocket-Protocol: sample

Diff:

-WebSocket-Protocol: sample
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment