cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLOPT_WRITEFUNCTION question

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Tue, 6 May 2008 10:44:41 -0700

On Tue, May 06, 2008 at 12:34:36PM -0400, Scott Rallya wrote:
> I had a question regarding the mechanics of libcurl and the
> CURLOPT_WRITEFUNCTION option. In the call-back I wrote, in the event of a write
> failure instead of returning 0 I set a flag indicating an error occured and
> return the total size of the buffer passed in. I do a check on this flag, and
> if the flag is set to true I don't write anything over a socket but continue to
> return the total size of the buffer. The reasoning is that in the event of a
> write failure I want to read in all the data from the backend server anyways.
> Is this something that would be well handled within libcurl? Is there any

How would libcurl do it any differently than your callback? In most case
of a write problem, there is no point in downloading any remaining data only
to throw it away.

> situation, for example, that doing it this way will force curl to sit waiting
> to read in data from the backend server instead of otherwise returning an error
> and aborting the transfer?

If there is a network or server problem after this situation occurs, then
yes, this method could mean that your app will sit waiting for a while for
data that may or may not eventually come.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2008-05-06