curl-library
Re: Problem setting CURLOPT_WRITEDATA to NULL
Date: Sat, 24 Jul 2010 23:08:27 +0200 (CEST)
On Sat, 24 Jul 2010, Simon Elliott wrote:
>> Just where do you expect the data to go in that case? The default write
>> callback function is fwrite, so if you set WRITEDATA to NULL, fwrite will
>> attempt to write to a NULL file handle.
>
> I assumed that setting the CURLOPT_NOBODY option to 1 would mean that no
> fwrite would take place. This is implied by the docs for CURLOPT_PREQUOTE,
> and there are some messages in the mailing list which suggest that this is
> the case for FTP but not for SFTP.
It would depend on a few other options as well.
> I also assumed that setting WRITEDATA to NULL would cause libcurl to revert
> to its internal file handle, but this isn't in the docs
Right, there's no such logic in libcurl. Once you've set WRITEDATA to
something, there's no way to switch it back to default like it was before you
first changed it. It would be a bit weird to have it work like that since it
would only make sense if you also had the WRITEFUNCTION set back to default
and it would make the options get a slightly hard-to-follow dependency.
> This is for a "does this file exist on the server" function so that my app
> can avoid doing any work if it doesn't find a particular flag file. Maybe I
> should be looking at another approach for "does this file exist"?
NOBODY is meant to be possible to use for exactly such kind of operations. I
don't think libcurl has any better means to do that.
-- / daniel.haxx.se ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2010-07-24