diff --git a/docs/libcurl/curl_ws_meta.md b/docs/libcurl/curl_ws_meta.md index 95505b0bda..202b20251b 100644 --- a/docs/libcurl/curl_ws_meta.md +++ b/docs/libcurl/curl_ws_meta.md @@ -124,6 +124,13 @@ reassemble the fragments to receive the complete message. Only a single fragmented message can be transmitted at a time, but it may be interrupted by CURLWS_CLOSE, CURLWS_PING or CURLWS_PONG frames. +## CURLWS_FIN + +This flag is set when the FIN bit is present in the received WebSocket frame. +In WebSocket protocol, the FIN bit indicates that this frame is the final +frame of the message. When CURLWS_FIN is set, it means no further frames +follow for this message. + # %PROTOCOLS% # EXAMPLE diff --git a/docs/libcurl/symbols-in-versions b/docs/libcurl/symbols-in-versions index 0b566edbc3..05f268c6fd 100644 --- a/docs/libcurl/symbols-in-versions +++ b/docs/libcurl/symbols-in-versions @@ -1146,6 +1146,7 @@ CURLWARNING 7.66.0 CURLWS_BINARY 7.86.0 CURLWS_CLOSE 7.86.0 CURLWS_CONT 7.86.0 +CURLWS_FIN 8.13.0 CURLWS_OFFSET 7.86.0 CURLWS_PING 7.86.0 CURLWS_PONG 7.86.0 diff --git a/include/curl/websockets.h b/include/curl/websockets.h index 6ef6a2bc92..926bd53d5d 100644 --- a/include/curl/websockets.h +++ b/include/curl/websockets.h @@ -43,6 +43,7 @@ struct curl_ws_frame { #define CURLWS_CLOSE (1<<3) #define CURLWS_PING (1<<4) #define CURLWS_OFFSET (1<<5) +#define CURLWS_FIN (1<<6) /* * NAME curl_ws_recv() diff --git a/lib/ws.c b/lib/ws.c index 2ce0b48455..d9498f2f87 100644 --- a/lib/ws.c +++ b/lib/ws.c @@ -195,6 +195,8 @@ static CURLcode ws_dec_read_head(struct ws_decoder *dec, } dec->frame_flags = ws_frame_op2flags(dec->head[0]); + dec->frame_flags = dec->frame_flags | + ((dec->head[0] & WSBIT_FIN) ? CURLWS_FIN : 0); if(!dec->frame_flags) { failf(data, "WS: unknown opcode: %x", dec->head[0] & WSBIT_OPCODE_MASK); diff --git a/tests/data/test2302 b/tests/data/test2302 index 9ade6a1e52..a81864a43d 100644 --- a/tests/data/test2302 +++ b/tests/data/test2302 @@ -64,7 +64,7 @@ Sec-WebSocket-Key: NDMyMTUzMjE2MzIxNzMyMQ== 68 65 6c 6c 6f -RECFLAGS: 1 +RECFLAGS: 41