Re: websocket HTTP response parsing

On Thu, 3 Jul 2008, Julian Reschke wrote:
> > 
> > Read the first 75 bytes from the server. If the connection closes 
> > before 75 bytes are received, or if the first 75 bytes aren't exactly 
> > equal to the following bytes, then fail the Web Socket connection and 
> > abort these steps.
> > 
> > 48 54 54 50 2f 31 2e 31 20 31 30 31 20 53 77 69 74 63 68 69 6e 67 20 
> > 50 72 6f 74 6f 63 6f 6c 73 0d 0a 55 70 67 72 61 64 65 3a 20 57 65 62 
> > 53 6f 63 6b 65 74 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 55 70 67 
> > 72 61 64 65 0d 0a
> > 
> > The string "HTTP/1.1 101 Switching Protocols", CRLF, the string 
> > "Upgrade: WebSocket", CRLF, the string "Connection: Upgrade", CRLF.
> 
> Besides the obvious spec readability problem (why confuse people with 
> hex dumps?), why does the spec assign any importance of the reason 
> phrase, when RFC2616 clearly says:
> 
> "The Reason-Phrase is intended to give a short textual description of 
> the Status-Code. The Status-Code is intended for use by automata and the 
> Reason-Phrase is intended for the human user." -- 
> <http://greenbytes.de/tech/webdav/rfc2616.html#rfc.section.6.1.1.p.1>

This isn't HTTP. It's WSP (Web Socket Protocol), which while it may 
vaguely look like HTTP in the handshake, really isn't HTTP and shouldn't 
be treated like HTTP.

(The hex blob is partially to emphasise this, and partially to make sure 
people get it exactly right, as it's much harder to get a hex dump wrong 
than a string with spaces in it, which might wrap in unfortunate ways.)

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Thursday, 3 July 2008 08:56:41 UTC