Skip to content

WebSockets_API/Writing_WebSocket_servers - Need thorough example for “If the MASK bit was set… read the next 4 octets (32 bits)” #18196

Closed
@ghost

Description

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers

What specific section or headline is this issue about?

Reading and Unmasking the Data

What information was incorrect, unhelpful, or incomplete?

An example is given in which a string is attempted to be mutated:

var DECODED = "";
for (var i = 0; i < ENCODED.length; i++) {
    DECODED[i] = ENCODED[i] ^ MASK[i % 4];
}

This would do nothing, or throw an exception in strict mode.

Update: This was fixed, but ideally we should use the WebSocket API to adequately explain and document what the page shows.

What did you expect to see?

Possibly a functional example, or as it is described in the article, a "pseudo-code" example, that's intentionally not (invalid) JavaScript.

Do you have any supporting links, references, or citations?

N/A.

Do you have anything more you want to share?

No response

MDN metadata

Page report details

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions