Upgrade typically fails because the request is not a handshake, not
because the handshake is malformed. To help developers diagnose the
common case, state explicitly that the request is not a handshake in
error messages.
To help diagnose malformed requests, capitalize and 'quote' header names
in error messages.
Update the error messages for missing 'Connection: upgrade' and
'Upgrade: websocket' tokens to indicate that the header might not be
present. The previous error message implied that the header is present,
but has the wrong value. This leads to some confusion for those
debugging connection problems.
Update the default origin test to treat no origin specified as OK. If
the client can create a request without the origin set, then the client
can also create a request with an arbitrary origin.
- Revert back to using Subprotocols []string. The protocol negotiation
using Subprotocols should meet the needs of most applications.
Applications are not locked into using this negotiation. An
application can pick a protocol some other way and specify the
protocol using the Sec-Websocket-Protocol response header.
- Parse the origin using url.Parse. This is the correct function to use
when parsing a full URL.
- Improve comments.
- Introduce ReadMessage and WriteMessage before NextReader and
NextWriter in the package comment. It's better to introduce the easy
methods first.
- Move sections on message of types before the concurrency section.