cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Perl WWW::Curl::Easy equivalent of PHP's CURLOPT_RETURNTRANSFER

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 19 Nov 2009 20:22:20 +0100 (CET)

On Thu, 19 Nov 2009, admin_at_azuni.net wrote:

>> With the C API and basically all existing bindings as well (including the
>> PHP one) you can use a write callback to append all data to a single
>> buffer.
>>
> From the tutorial at http://curl.haxx.se/libcurl/c/libcurl-tutorial.html
> I guess
> size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp);
> curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, write_data);

Exactly. And CURLOPT_WRITEDATA to set the custom pointer passed to the
callback.

> which in Perl would probably translate to
> sub write_data($$$$) { ... }
> $curl->setopt(CURLOPT_WRITEFUNCTION, \&write_data);
>
> Can you please tell me how to use that?

Well, I'm not a user of the perl binding but I looked at their package and it
is strange that I can find them but you obviously can't:

http://cpansearch.perl.org/src/SZBALINT/WWW-Curl-4.09/t/02callbacks.t

> How can I check for that? WWW::Curl seems to be a thin Perl wrapper around a
> .so library, so I don't have the source code to look at.

Both WWW::Curl and libcurl are 100% open source with source code available,
you can indeed get the source to look at. If you want to.

Now we should drop this subject on this mailing list. We're far away from PHP
now...

--
  / daniel.haxx.se
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-11-19