websocket: support CURLOPT_READFUNCTION

Add support for CURLOPT_READFUNCTION with WebSocket urls when
    *not* in connect-only mode, e.g. when using curl_multi_perform.

    Install the callback function and set CURLOPT_UPLOAD. Return
    CURL_READFUNC_PAUSE when having nothing more to send and unpause
    the transfer when more data is ready.

    This will send the read bytes in a WebSocket BINARY frame.

    Add support for this mode in the pytest "ws_data" client and
    have all tests run in 'curl_ws_send/recv' and 'peform' mode
    as well.

    Add `curl_ws_start_frame()`. Document, cover in libcurl-ws.md
    and explain the READFUNCTION mode for websockets.

    Add example `websocket-updown` for this.
This commit is contained in:
Stefan Eissing 2025-07-08 09:15:43 +02:00
parent 4108d11008
commit 454beb711b
No known key found for this signature in database
16 changed files with 863 additions and 153 deletions

View file

@ -154,6 +154,7 @@ my %api = (
'curl_ws_meta' => 'API',
'curl_ws_recv' => 'API',
'curl_ws_send' => 'API',
'curl_ws_start_frame' => 'API',
# the following functions are provided globally in debug builds
'curl_easy_perform_ev' => 'debug-build',