aboutsummaryrefslogtreecommitdiff
path: root/lib/websocket/frames.go
AgeCommit message (Collapse)Author
2026-01-03all: use SPDX license header formatShulhan
2023-07-01lib/websocket: reformat comments and documentationShulhan
2022-06-09lib/websocket: refactoring codeShulhan
Replace assignment from using ":=" to use variable declaration with type. Rationale: clarity and minimize duplicate temporary variables with the same type.
2022-05-09all: reformat all codes using gofmt 1.19 (the Go tip)Shulhan
2020-08-11websocket: reformat some filesShulhan
2019-03-17websocket: simplify handling chopped frameShulhan
Previously, we use two function to unpack frame: frameUnpack and continueUnpack, both of this functions actually use the same logic. This commit merge both functions into Frame's unpack() and which also make handleChopped() to be unused on both server and client.
2019-03-17websocket: add method to merge all continuous framesShulhan
The method is called fin() with single parameter: the last frame that contains finished state. Also, use the Frames.fin method on ClientManager.finFrames, to minimize duplicate code.
2019-03-12websocket: export the opcode typeShulhan
The opcode type is required to create new frame and to get the opcode in continous frames.
2019-03-12websocket: unexport internal methods and remove unused methodsShulhan
Some of the methods in ClientManager and Frames should be only accessed by internal server, not by implementor.
2019-03-11websocket: handle chopped frame with interjected control frameShulhan
Another possibility is fragmented frames with one of the frame is chopped and in the middle of it is a control FRAME. For example, C> Frame{fin:false opcode:TEXT len:1024 payload:512} C> payload:512 FRAME{fin:TRUE opcode:PING len:0} C> Frame{fin:true opcode:0 len:1024 payload:1024}
2019-03-10websocket: handle invalid packet when unpacking websocket frameShulhan
Most of the cases involving out-of-range index, most of notable cases are, * masked frame without masked data * empty payload or payload data that contains data less than defined in payload length * control close frame without close code
2019-03-06websocket: explain why Unpack return multiple framesShulhan
When receiving packet from client, the underlying protocol or operating system may buffered the packet. Client may send a single frame one at time, but server may receive one or more frame in one packet; and vice versa. That's the reason why the Unpack return multiple frame instead of single frame.
2019-03-06websocket: ignore control frame when concatenating payloadShulhan
Control frame actually directly handled by server when processing received frames from client. This condition is just to make sure that we are not messing the payload in case the Frames is used by client.
2019-03-05websocket: change the Unpack return type to FramesShulhan
Continuing refactor, the Frames type provide methods than can used to handle packet from other endpoint.
2019-03-05websocket: unexported the Frame fields Fin and MaskedShulhan
Continuing refactor, this commit unexport all fields in Frame to allow user focus working with method and packet, let the technical detail managed by library.
2019-03-04websocket: minimize global variables and unexport internal constantsShulhan
Most of the constants should not be used directly, as we prefer user to use the functions or methods based access.
2019-03-04websocket: add type for continuous (fragmented) frameShulhan
A type Frames is actually a wrapper to slice of frame. We prefer if user is not directly access to underlying frames but focus on payload instead.