diff options
author | Daniel Stenberg <daniel@haxx.se> | 2022-10-03 17:40:02 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2022-10-07 12:50:58 +0200 |
commit | e3f335148adc6742728ff8fef4a011d42fa5c7b1 (patch) | |
tree | 8529eeb08b6dd008a7bcee6a2836a428cecfcfcd /lib/http.h | |
parent | 83de62babc6d54da033477f3e6ba6af5b6c68663 (diff) | |
download | curl-e3f335148adc6742728ff8fef4a011d42fa5c7b1.tar.gz |
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
Diffstat (limited to 'lib/http.h')
-rw-r--r-- | lib/http.h | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/lib/http.h b/lib/http.h index 4ba4b2bbb..f7cbb3424 100644 --- a/lib/http.h +++ b/lib/http.h @@ -202,17 +202,6 @@ struct h3out; /* see ngtcp2 */ #endif /* _WIN32 */ #endif /* USE_MSH3 */ -struct websockets { - bool contfragment; /* set TRUE if the previous fragment sent was not final */ - unsigned char mask[4]; /* 32 bit mask for this connection */ - struct Curl_easy *data; /* used for write callback handling */ - struct dynbuf buf; - size_t usedbuf; /* number of leading bytes in 'buf' the most recent complete - websocket frame uses */ - struct curl_ws_metadata handout; /* the struct storage used for - curl_ws_meta() returns */ -}; - /**************************************************************************** * HTTP unique setup ***************************************************************************/ @@ -240,7 +229,7 @@ struct HTTP { } sending; #ifdef USE_WEBSOCKETS - struct websockets ws; + struct websocket ws; #endif #ifndef CURL_DISABLE_HTTP |