curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: Couple cuestions about CURLOPT_WRITEFUNCTION callback

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 14 Feb 2017 00:23:26 +0100 (CET)

On Mon, 13 Feb 2017, David Requena wrote:

>> "as soon as possible"
>
> There's exactly one absolute interpretation for ASAP in this context: as
> soon as 1 byte is received. It's absolutely impossible relaying data before
> having it. Any other interpretation would require qualification as to how
> much data, time or whatever other factors involved.

Right, but I don't think we can qualify that much in any meaningful way in the
docs. There are simply too many variables involved.

libcurl reads data from the socket, then sends it to the application.

> - Client sends some http request
> - Server sends response headers: content-type text/eventstream, etc
> - Server does not close the connection and starts sending small, say 30
> bytes a piece, text items every 1 or 2 seconds.
> - The client is supposed to act on those events as they are received.
>
> Now, if libcurl is willing to fillup a 16KB data buffer before invoking
> CURLOPT_WRITEFUNCTION

To me, that would be a very weird defintion of "as soon as possible".

If the server sends 30 bytes chunks, chances are your application will get
those 30 bytes in one or maybe two callbacks.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2017-02-14