curl-users
Re: libcurl, -w option
Date: Fri, 29 Sep 2000 08:55:02 +0200 (MET DST)
On Thu, 28 Sep 2000, Georg Horn wrote:
> (I think of building a perl-interface to libcurl, because calling curl as
> an external program from my perl-scripts does not really increase
> performance, i think... ;-))
I would really enjoy having a perl-interface to it...
> Now i wrote a small test programm and did:
>
> char writeoutbuf[80];
> ...
> strcpy(writeoutbuf, "%{size_download} bytes\\n");
> curl_easy_setopt(curl_handle, CURLOPT_WRITEINFO, writeoutbuf);
>
> but the program just prints out "xyz bytes" when calling curl_easy_perform().
*blushes*
Yes, the silly function has no way of sending the information to anything but
to stdout! This is nothing I've planned to keep, it just happened to become
like this. Let's figure out how to improve this!
> bytes = curl_easy_getout(curl_handle, CURLOUT_SIZE_DOWNLOAD);
>
> or an option that makes libcurl store the string, that is now printed to
> stdout when specifying the -w switch, into a charcter buffer?
Originally, I planned to have the whole -w functionality put outside of the
library and, as you describe above here, provide functionality in libcurl
that allows applications to "suck out" the information they need.
Now, we can still keep the -w code in the lib for a while more, but we can
indeed introduce a curl_easy_getout() function.
> This would provide a more complete interface to the users of libcurl, as
> after calling curl_easy_perform() they had access to the variables that
> can otherwise only be printed with -w
It would be neat.
> Or how can this be done? Using the lowlevel function curl_read() from
> libcurl and counting the bytes by oneself?
Today, if you don't wanna capture the stdout, you'd use curl_easy_setopt() to
set a write callback, and within that you'd count the bytes being written.
-- Daniel Stenberg -- curl project maintainer -- http://curl.haxx.se/Received on 2000-09-29