cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: some observation with read callback

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 21 Feb 2008 18:30:32 +0100 (CET)

On Thu, 21 Feb 2008, Guenter Knauf wrote:

> I saw that the callback gets always called one time more as needed. F.e. I
> had a text file with 26 bytes which I would assume that it fits into the
> buffer; but anyhow I get _two_ calls to the callback: the first reads 26
> bytes, and the second 0.

Ah, yes. There's no code in Curl_readwrite() that checks if the total amount
has reached the amount of data previously set. But on the other hand there's
nothing that prevents the read callback to provide more data than what was
previously set... IOW, there is actually a small risk that there are users who
would be hurt by the addition of a check here. But in general that would
rather be an indication of a problem in their code and not in libcurl.

It should also be easy enough to make a test case that verifies this when we
address it, or possibly even adjust one of the existing ones to make sure we
don't need any bonus callback calls.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2008-02-21