cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Not Getting Error Messages using curl_easy API in C (New User)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 18 Nov 2005 01:01:04 +0100 (CET)

On Thu, 17 Nov 2005, jamie page wrote:

(consider using the curl-library list for libcurl stuff, it's made for this
purpose!)

> I'm involved in a small project using curl. The goal is to collect pages
> from a local server. When I test with an Invalid URL, I'm hoping to get an
> error to handle. However what I'm getting is an error page downloaded and
> written to disk.

Sure, curl downloads what you ask it.

> Is there away to gain an error code to allow error handling?

yes

> if(curl_easy_getinfo(ctxHttps->curl, CURLINFO_HTTP_CODE, &lCurlResponse
> != CURLE_OK)

Did that code really compile? It is completely wrong. After your transfer, do:

  long code;

  curl_easy_getinfo(curl, CURLINFO_HTTP_CODE, &code);

... and then 'code' will contain the HTTP response code from your request.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2005-11-18