Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/websocket: unclear whether Conn.Read documentation refers to frame or message #71107

Open
fortuna opened this issue Jan 3, 2025 · 1 comment
Labels
Documentation Issues describing a change to documentation. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@fortuna
Copy link

fortuna commented Jan 3, 2025

Go version

any

Output of go env in your module/workspace:

N/A

What did you do?

The behavior of websocket.Conn is not clear.

What did you see happen?

In https://pkg.go.dev/golang.org/x/net/websocket#Conn.Read, we have:

Read implements the io.Reader interface: it reads data of a frame from the WebSocket connection. if msg is not large enough for the frame data, it fills the msg and next Read will read the rest of the frame data. it reads Text frame or Binary frame.

Does Read read a frame or a message? The text keeps saying "frame", but it actually sounds like a message, or else we don't have a way to get messages. The variable says "msg".

There's more confusion in the documentation. In one of the examples we have:

// receive text frame
var message string
websocket.Message.Receive(ws, &message)

Is it a frame or a message?

What did you expect to see?

In Websockets frames and messages are two different things with well defined meaning in the RFC. This needs to be clarified.

@gopherbot gopherbot added this to the Unreleased milestone Jan 3, 2025
@gopherbot gopherbot added the Documentation Issues describing a change to documentation. label Jan 3, 2025
@gabyhelp
Copy link

gabyhelp commented Jan 3, 2025

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@dmitshur dmitshur changed the title x/net: unclear websocket documentation: frame or message? x/net/websocket: unclear whether Conn.Read documentation refers to frame or message Jan 3, 2025
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues describing a change to documentation. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants