cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Output to terminal using libcurl

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

On Thu, Mar 17, 2011 at 13:51, Oscar Salvador <pyscholeber_at_gmail.com> wrote:
> Hi, how are you.
> I have a doubt with libcurl. I'm retrieving an image from url, for
> example: http://www.jejeje.com/pepe/52.jpg, 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: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-03-17