JiKeidan

Untitled

May 22nd, 2012
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. Once the client's opening handshake has been sent, the client MUST
  2. wait for a response from the server before sending any further data.
  3. The client MUST validate the server's response as follows:
  4.  
  5. 1. If the status code received from the server is not 101, the
  6. client handles the response per HTTP [RFC2616] procedures. In
  7. particular, the client might perform authentication if it
  8. receives a 401 status code; the server might redirect the client
  9. using a 3xx status code (but clients are not required to follow
  10. them), etc. Otherwise, proceed as follows.
  11.  
  12. 2. If the response lacks an |Upgrade| header field or the |Upgrade|
  13. header field contains a value that is not an ASCII case-
  14. insensitive match for the value "websocket", the client MUST
  15. _Fail the WebSocket Connection_.
  16.  
  17. 3. If the response lacks a |Connection| header field or the
  18. |Connection| header field doesn't contain a token that is an
  19. ASCII case-insensitive match for the value "Upgrade", the client
  20. MUST _Fail the WebSocket Connection_.
  21.  
  22. 4. If the response lacks a |Sec-WebSocket-Accept| header field or
  23. the |Sec-WebSocket-Accept| contains a value other than the
  24. base64-encoded SHA-1 of the concatenation of the |Sec-WebSocket-
  25. Key| (as a string, not base64-decoded) with the string "258EAFA5-
  26. E914-47DA-95CA-C5AB0DC85B11" but ignoring any leading and
  27. trailing whitespace, the client MUST _Fail the WebSocket
  28. Connection_.
  29.  
  30. 5. If the response includes a |Sec-WebSocket-Extensions| header
  31. field and this header field indicates the use of an extension
  32. that was not present in the client's handshake (the server has
  33. indicated an extension not requested by the client), the client
  34. MUST _Fail the WebSocket Connection_. (The parsing of this
  35. header field to determine which extensions are requested is
  36. discussed in Section 9.1.)
  37.  
  38. Fette & Melnikov Standards Track [Page 19]
  39. RFC 6455 The WebSocket Protocol December 2011
  40.  
  41. 6. If the response includes a |Sec-WebSocket-Protocol| header field
  42. and this header field indicates the use of a subprotocol that was
  43. not present in the client's handshake (the server has indicated a
  44. subprotocol not requested by the client), the client MUST _Fail
  45. the WebSocket Connection_.
  46.  
  47. If the server's response does not conform to the requirements for the
  48. server's handshake as defined in this section and in Section 4.2.2,
  49. the client MUST _Fail the WebSocket Connection_.
  50.  
  51. Please note that according to [RFC2616], all header field names in
  52. both HTTP requests and HTTP responses are case-insensitive.
  53.  
  54. If the server's response is validated as provided for above, it is
  55. said that _The WebSocket Connection is Established_ and that the
  56. WebSocket Connection is in the OPEN state. The _Extensions In Use_
  57. is defined to be a (possibly empty) string, the value of which is
  58. equal to the value of the |Sec-WebSocket-Extensions| header field
  59. supplied by the server's handshake or the null value if that header
  60. field was not present in the server's handshake. The _Subprotocol In
  61. Use_ is defined to be the value of the |Sec-WebSocket-Protocol|
  62. header field in the server's handshake or the null value if that
  63. header field was not present in the server's handshake.
  64. Additionally, if any header fields in the server's handshake indicate
  65. that cookies should be set (as defined by [RFC6265]), these cookies
  66. are referred to as _Cookies Set During the Server's Opening
  67. Handshake_.
Advertisement
Add Comment
Please, Sign In to add comment