curl-library
Re: Libcurl server-sent events (SSE) write callback notification
Date: Thu, 14 Feb 2019 09:08:50 +0100 (CET)
On Wed, 13 Feb 2019, Chris Dolfin via curl-library wrote:
> http://www.w3.org/TR/eventsource
To me, this is just a HTTP stream that may potentially stick around for a long
time. Nothing strange for libcurl.
> Libcurl always call the “write callback” when it receives HTTP response and
> stores the data in the structure provided by the user.
Yes. Well libcurl calls the callback zero, one or many times, whether the
application stores that data or not is of course entirely up to it.
> In normal request curl_easy_perform(,,) returns and I know that there is
> data in my buffer.
If it returned ok, the response data had a non-zero length and your callback
stored it, sure.
> At this stage I know that there is data in readBuffer.
>
> At this stage the server will send more data and WriteCallback will be
> called to write data to readBuffer.
No.
For these long-going HTTP streams, curl_easy_perform() will not return until
the connection closes and that might take a long time until it does. And for
most situaitons, I would imagine that you'd just loop then and do another
request again to allow for more "events" to arrive.
While curl_easy_perform() sits waiting for more events nothing happens but as
soon as data arrives it will call the write callback and your application can
deal with it.
> I cannot call curl_easy_perform() because I should not send new request.
If the connection breaks I figure you should...
-- / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-02-14