Websocket documentation error ? #2408
-
Hi, The websocket documentation here says that the flags element corresponds to the first byte as described in RFC 6455 section 5.2. But when we look at the RFC the opcode is bits 4,5,6,7 while with the flags the opcode is bits 0,1,2,3. The example makes it pretty clear by doing "msgtype = wm->flags & 0x0F;" to get the opcode. This brings another question, if the flags element does not contain the FIN bit, that means we can not detect fragmented websocket messages, Does that mean that Mongoose automatically buffers and de-fragments a fragmented websocket message and thus only issue one MG_EV_WS_MSG event when the final fragment is received ? Regards. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
https://datatracker.ietf.org/doc/html/rfc6455#section-5.2 :
We don't strip anything, you just don't need to use that, because: Line 72 in cb1ae31 Line 179 in cb1ae31 Lines 211 to 230 in cb1ae31 Mongoose buffers the fragments |
Beta Was this translation helpful? Give feedback.
https://datatracker.ietf.org/doc/html/rfc6455#section-5.2 :
msg->flags
is not the actual byte in the WS frame, but a copy of it. The order of the bytes in the frame is as seen left to right, and the order of the bits is MSb to LSb left to right. The docs explainmsg->flags
and that is nevertheless coincident with that.We don't strip anything, you just don't need to use that, because:
mongoose/src/ws.c
Line 72 in cb1ae31
mongoose/src/ws.c
Line 179 in cb1ae31
mongoose/src/ws.c
Lines 211 to 230 in c…