In PHP API we could us开发者_StackOverflowe curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
but how to translate it into C? I tried curl_easy_setopt(curl_handle, CURLOPT_RETURNTRANSFER, true);
but failed.
There's no CURLOPT_RETURNTRANSFER
in libcurl C API. You can do that with a callback function, it's one of libcurls examples: get a remote file in memory only.
I think this mailing list entry is relevant:
http://curl.haxx.se/mail/curlphp-2009-11/0005.html
CURLOPT_RETURNTRANSFER was invented by the PHP binding author and is basically just a shortcut for appending all received data into a memory buffer. 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.
精彩评论