]> git.ipfire.org Git - thirdparty/curl.git/commit
websockets: remodeled API to support 63 bit frame sizes
authorDaniel Stenberg <daniel@haxx.se>
Mon, 3 Oct 2022 15:40:02 +0000 (17:40 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 7 Oct 2022 10:50:58 +0000 (12:50 +0200)
commite3f335148adc6742728ff8fef4a011d42fa5c7b1
tree8529eeb08b6dd008a7bcee6a2836a428cecfcfcd
parent83de62babc6d54da033477f3e6ba6af5b6c68663
websockets: remodeled API to support 63 bit frame sizes

curl_ws_recv() now receives data to fill up the provided buffer, but can
return a partial fragment. The function now also get a pointer to a
curl_ws_frame struct with metadata that also mentions the offset and
total size of the fragment (of which you might be receiving a smaller
piece). This way, large incoming fragments will be "streamed" to the
application. When the curl_ws_frame struct field 'bytesleft' is 0, the
final fragment piece has been delivered.

curl_ws_recv() was also adjusted to work with a buffer size smaller than
the fragment size. (Possibly needless to say as the fragment size can
now be 63 bit large).

curl_ws_send() now supports sending a piece of a fragment, in a
streaming manner, in addition to sending the entire fragment in a single
call if it is small enough. To send a huge fragment, curl_ws_send() can
be used to send it in many small calls by first telling libcurl about
the total expected fragment size, and then send the payload in N number
of separate invokes and libcurl will stream those over the wire.

The struct curl_ws_meta() returns is now called 'curl_ws_frame' and it
has been extended with two new fields: *offset* and *bytesleft*. To help
describe the passed on data chunk when a fragment is delivered in many
smaller pieces.

The documentation has been updated accordingly.

Closes #9636
12 files changed:
docs/libcurl/curl_ws_meta.3
docs/libcurl/curl_ws_recv.3
docs/libcurl/curl_ws_send.3
docs/libcurl/symbols-in-versions
include/curl/websockets.h
lib/easy.c
lib/easyif.h
lib/http.h
lib/ws.c
lib/ws.h
tests/libtest/lib2301.c
tests/libtest/lib2302.c