Hi,

bytesleft == 0 means no more data in this frame.
bytesleft == 0 and CURLWS_CONT bit is not set means the end of the message.

--
Mike


ср, 12 июл. 2023 г. в 13:00, <curl-library-requ...@lists.haxx.se>:

> Send curl-library mailing list submissions to
>         curl-library@lists.haxx.se
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.haxx.se/mailman/listinfo/curl-library
> or, via email, send a message with subject or body 'help' to
>         curl-library-requ...@lists.haxx.se
>
> You can reach the person managing the list at
>         curl-library-ow...@lists.haxx.se
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of curl-library digest..."
>
>
> Today's Topics:
>
>    1. Detecting final WebSocket frame of a fragmented message
>       (Paul Fotheringham)
>    2. RE: Detecting final WebSocket frame of a fragmented message
>       (Dmitry Karpov)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 11 Jul 2023 17:35:19 +0100
> From: Paul Fotheringham <fotheringham.p...@gmail.com>
> To: curl-library@lists.haxx.se
> Subject: Detecting final WebSocket frame of a fragmented message
> Message-ID:
>         <CAGThwFanQ_A6MCmekV-f7tVCM=
> s2yg2cmdqhvirr41rz8gq...@mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"
>
> Hi,
>
> I've been using libcurl for some months now and recently tried to get
> WebSocket going in CURLOPT_CONNECT_ONLY=2L mode. The problem I'm
> having is if the server sends a message fragmented over multiple
> frames then I cannot work out how I am meant to know when the final
> frame of the message is received via curl_ws_recv. Even if it is not
> fragmented then I get the whole message but again I guess I don't know
> that the message is finished.
>
> My understanding of WebSocket is that only the final frame (might be
> the only frame) has the FIN bit set in the header but I see no
> corresponding exposure of that in the API and a quick scan of the code
> seems to suggest it is not being passed out in any way. The server is
> mine too so I may have a bug but at the same time I just don't see how
> I'm meant to detect the final frame.
>
> I understand WebSocket support is still experimental so I'm wondering
> if I am missing something or if this is just not available yet?
>
> Paul
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 11 Jul 2023 18:26:58 +0000
> From: Dmitry Karpov <dkar...@roku.com>
> To: libcurl development <curl-library@lists.haxx.se>
> Subject: RE: Detecting final WebSocket frame of a fragmented message
> Message-ID:
>         <
> byapr01mb5606ba7686ffc06c11b75a3fc3...@byapr01mb5606.prod.exchangelabs.com
> >
>
> Content-Type: text/plain; charset="us-ascii"
>
> I guess the "offset" and "bytesleft" in the curl_ws_meta structure (
> https://curl.se/libcurl/c/curl_ws_meta.html)
> provide information about WS message fragments.
>
> "offset"
> When this frame is a continuation of fragment data already delivered, this
> is the offset into the final fragment where this piece belongs.
>
> "bytesleft"
> If this is not a complete fragment, the bytesleft field informs about how
> many additional bytes are expected to arrive before this fragment is
> complete.
>
> I suppose that for the final frame in the WS message the "bytesleft" field
> should be set to zero thus indicating the end of the message.
>
> Thanks,
> Dmitry Karpov
>
>
>
> -----Original Message-----
> From: curl-library <curl-library-boun...@lists.haxx.se> On Behalf Of Paul
> Fotheringham via curl-library
> Sent: Tuesday, July 11, 2023 9:35 AM
> To: curl-library@lists.haxx.se
> Cc: Paul Fotheringham <fotheringham.p...@gmail.com>
> Subject: [EXTERNAL] Detecting final WebSocket frame of a fragmented message
>
> Hi,
>
> I've been using libcurl for some months now and recently tried to get
> WebSocket going in CURLOPT_CONNECT_ONLY=2L mode. The problem I'm having is
> if the server sends a message fragmented over multiple frames then I cannot
> work out how I am meant to know when the final frame of the message is
> received via curl_ws_recv. Even if it is not fragmented then I get the
> whole message but again I guess I don't know that the message is finished.
>
> My understanding of WebSocket is that only the final frame (might be the
> only frame) has the FIN bit set in the header but I see no corresponding
> exposure of that in the API and a quick scan of the code seems to suggest
> it is not being passed out in any way. The server is mine too so I may have
> a bug but at the same time I just don't see how I'm meant to detect the
> final frame.
>
> I understand WebSocket support is still experimental so I'm wondering if I
> am missing something or if this is just not available yet?
>
> Paul
> --
> Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
> Etiquette:   https://curl.se/mail/etiquette.html
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> --
> Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
> Etiquette:   https://curl.haxx.se/mail/etiquette.html
>
>
> ------------------------------
>
> End of curl-library Digest, Vol 24, Issue 4
> *******************************************
>
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to