Skip to content

Conform to protocol for identifying websockets handshake requests #8

Open
@astrieanna

Description

@astrieanna

From the websockets RFC:

  1. An Upgrade header field containing the value "websocket",
    treated as an ASCII case-insensitive value.
  2. A Connection header field that includes the token "Upgrade",
    treated as an ASCII case-insensitive value.
  3. A Sec-WebSocket-Key header field with a base64-encoded (see
    Section 4 of [RFC4648]) value that, when decoded, is 16 bytes in
    length.
  4. A Sec-WebSocket-Version header field, with a value of 13.

Currently, we look for an Upgrade header with the case-sensitive value "websocket".

If some but not all of the websockets properties hold, we should response with an appropriate error. Just not identifying non-complying requests as websockets handshakes should work out ok, but if it has any of the headers with "websocket" in the name or value (but does not follow all four), then I think we should response with an error at that point.

The Sec-Websocket-Key property can be determined by counting the total number of characters and the number of =-signs at the end of the value. 16 = 22 + 2=. (Meaning you don't actually have to decode it to figure out whether the length property holds.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions