cURL / Mailing Lists / curl-library / Single Mail


Re: Output to terminal using libcurl

From: Ben Noordhuis <>
Date: Thu, 17 Mar 2011 14:14:26 +0100

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.
List admin:
Received on 2011-03-17