cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLOPT_WRITEFUNCTION callback.

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 13 Aug 2001 17:04:53 +0200 (MET DST)

On Mon, 13 Aug 2001, Judith NATAF wrote:

> While sending an http request, I set several oprions :
>
> curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, my_write_data);
> curl_easy_setopt(curl_handle, CURLOPT_FILE, lp_data);
>
> But I just get a part of the datas in return : the callback
> "my_write_data" is launched only once with nmemb = 1131, instead of 15000
> Ko.

The callback will be called many times. The amount of data passed in each
invoke depends on your OS, network and more.

> I get the error message :
>
> * Closing live connection <#0>
> Failed writing body
>
> Should the callback be launched several times or only once with the whole
> data ? How comes the connection is shut before the end of receiving datas
> ?

I think it looks as if you don't return the correct return code. Your
callback function must return the amount of bytes you took care of, which
should be the same amount that was passed to you. Unless you do that, libcurl
will treat it as an error and cancel the transfer.

If that isn't the case, we need more details to figure out what it is.

-- 
     Daniel Stenberg -- curl dude -- http://curl.haxx.se/
_______________________________________________
Curl-library mailing list
http://curl.haxx.se/libcurl/
Received on 2001-08-13