cURL / Mailing Lists / curl-library / Single Mail


Re: Output to terminal using libcurl

From: Lars Nilsson <>
Date: Thu, 17 Mar 2011 09:39:16 -0400

On Thu, Mar 17, 2011 at 9:14 AM, Ben Noordhuis <> wrote:
> On Thu, Mar 17, 2011 at 13:51, Oscar Salvador <> wrote:
>> Hi, how are you.
>> I have a doubt with libcurl. I'm retrieving an image from url, for
>> example:, and i save this in a
>> memory buffer. This works correctly.
>> Before retrieve the image, I check if image exists or no with:
>> [[ curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &http_code); ]]
>> If http_code contains "404", i close libcurl and return to he previous
>> function, but when i call curl_perform to see if image exists, i get
>> the output to the terminal.
>> Is there any solution for don't send to terminal?
> Set CURLOPT_FAILONERROR to 1. You won't have to do a separate 404
> check and your write function won't be called it if the HTTP status
> code >= 300.

Additional comment, if the function is supposed to be called multiple
times during the liftetime of the process (couldn't say since the code
is not a complete program..), you'd want to get rid of the global init
and cleanup in the function and put them at the start of the program
and before exiting. It is not supposed to be done for each transfer.

Lars Nilsson
List admin:
Received on 2011-03-17