Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Once the client's opening handshake has been sent, the client MUST
- wait for a response from the server before sending any further data.
- The client MUST validate the server's response as follows:
- 1. If the status code received from the server is not 101, the
- client handles the response per HTTP [RFC2616] procedures. In
- particular, the client might perform authentication if it
- receives a 401 status code; the server might redirect the client
- using a 3xx status code (but clients are not required to follow
- them), etc. Otherwise, proceed as follows.
- 2. If the response lacks an |Upgrade| header field or the |Upgrade|
- header field contains a value that is not an ASCII case-
- insensitive match for the value "websocket", the client MUST
- _Fail the WebSocket Connection_.
- 3. If the response lacks a |Connection| header field or the
- |Connection| header field doesn't contain a token that is an
- ASCII case-insensitive match for the value "Upgrade", the client
- MUST _Fail the WebSocket Connection_.
- 4. If the response lacks a |Sec-WebSocket-Accept| header field or
- the |Sec-WebSocket-Accept| contains a value other than the
- base64-encoded SHA-1 of the concatenation of the |Sec-WebSocket-
- Key| (as a string, not base64-decoded) with the string "258EAFA5-
- E914-47DA-95CA-C5AB0DC85B11" but ignoring any leading and
- trailing whitespace, the client MUST _Fail the WebSocket
- Connection_.
- 5. If the response includes a |Sec-WebSocket-Extensions| header
- field and this header field indicates the use of an extension
- that was not present in the client's handshake (the server has
- indicated an extension not requested by the client), the client
- MUST _Fail the WebSocket Connection_. (The parsing of this
- header field to determine which extensions are requested is
- discussed in Section 9.1.)
- Fette & Melnikov Standards Track [Page 19]
- RFC 6455 The WebSocket Protocol December 2011
- 6. If the response includes a |Sec-WebSocket-Protocol| header field
- and this header field indicates the use of a subprotocol that was
- not present in the client's handshake (the server has indicated a
- subprotocol not requested by the client), the client MUST _Fail
- the WebSocket Connection_.
- If the server's response does not conform to the requirements for the
- server's handshake as defined in this section and in Section 4.2.2,
- the client MUST _Fail the WebSocket Connection_.
- Please note that according to [RFC2616], all header field names in
- both HTTP requests and HTTP responses are case-insensitive.
- If the server's response is validated as provided for above, it is
- said that _The WebSocket Connection is Established_ and that the
- WebSocket Connection is in the OPEN state. The _Extensions In Use_
- is defined to be a (possibly empty) string, the value of which is
- equal to the value of the |Sec-WebSocket-Extensions| header field
- supplied by the server's handshake or the null value if that header
- field was not present in the server's handshake. The _Subprotocol In
- Use_ is defined to be the value of the |Sec-WebSocket-Protocol|
- header field in the server's handshake or the null value if that
- header field was not present in the server's handshake.
- Additionally, if any header fields in the server's handshake indicate
- that cookies should be set (as defined by [RFC6265]), these cookies
- are referred to as _Cookies Set During the Server's Opening
- Handshake_.
Advertisement
Add Comment
Please, Sign In to add comment