websocket: improve handling of 0-len frames

Write out 9-length frames to client's WRITEFUNCTION
Read 0-length frames from READFUNCTION *if* the function
started a new frame via `curl_ws_start_frame()`.

Fixes #18286
Closes #18332
Reported-by: Andriy Druk
This commit is contained in:
Stefan Eissing 2025-08-18 17:12:35 +02:00 committed by Daniel Stenberg
parent fd2a204c23
commit fa3baabbd8
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
11 changed files with 275 additions and 141 deletions

View file

@ -46,6 +46,14 @@ the data belonging to the frame.
The function fails, if a previous frame has not been completely
read yet. Also it fails in *CURLWS_RAW_MODE*.
The read function in libcurl usually treats a return value of 0
as the end of file indication and stops any further reads. This
would prevent sending WebSocket frames of length 0.
If the read function calls `curl_ws_start_frame()` however, a return
value of 0 is *not* treated as an end of file and libcurl calls
the read function again.
# FLAGS
Supports all flags documented in curl_ws_meta(3).