cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: stop downloading after x bytes?

From: Andrew <andrew_at_donehue.net>
Date: Tue, 10 Jan 2006 22:53:56 +1100

Hi,

All working, thank you for your help. I remember reading this in the
libcurl documents, but obviously I misinterpreted it :(

Cheers,
Andrew

Daniel Stenberg wrote:

> On Tue, 10 Jan 2006, Andrew wrote:
>
>> I have tried calling the close function within the writedata
>> procedure.... however it segfaults :(
>
>
> That is perfectly understandable as you're effectively cutting off the
> branch you're sitting on when doing that.
>
>> - Is it possible to close the connection (without trying to free the
>> structure) from the writedata call itself (and then free from within
>> the main program)?
>
>
> That's not what you want to do. You want to *return* out from the
> callback and have the transfer aborted. And that is done by returning
> a failure from thr write callback (return any value that is not the
> total number of bytes you received as input).
>
> curl_easy_cleanup() etc should then be used by your app as normally.
>
Received on 2006-01-10