cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: File Exists

From: Charles <sanders-consulting_at_attbi.com>
Date: Mon, 23 Jun 2003 16:30:44 -0700

Check the return code after you download the page.

int main(void)
{
  CURL *curl;
  CURLcode res;
  long code;
  curl = curl_easy_init();

  if(curl) {

    curl_easy_setopt(curl, CURLOPT_URL, "http://www.servere.com/file.htm");
    res = curl_easy_perform(curl);
    curl_easy_getinfo(curl,CURLINFO_HTTP_CODE,&code);

    if (code == 404) { ... }

   curl_easy_cleanup(curl);
  }
  return 0;
}
----- Original Message -----
From: "Alex Salsinha" <manobro87_at_hotmail.com>
To: <curl-library_at_lists.sourceforge.net>
Sent: Friday, June 20, 2003 2:52 PM
Subject: File Exists

> Well, I´m tring to do a program that restrives a url, and if the page
> doesn´t exists, does a printf()
> Sayng:
>
> "The requested page doesn´t exist".
>
> I´m using this little and basic code using libcurl. But if the page
doesn´t
> exists it still restrieves something like this:
>
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
> <HTML><HEAD>
> <TITLE>404 Not Found</TITLE>
> </HEAD><BODY>
> <H1>Not Found</H1>
> The requested URL /file.htm was not found on this server.<P>
> <HR>
> <ADDRESS>Apache/1.3.27 Server at www.server.com Port 80</ADDRESS>
> </BODY></HTML>
>
>
> With this code:
>
> #include <stdio.h>
> #include <curl/curl.h>
>
> int main(void)
> {
> CURL *curl;
> CURLcode res;
>
> curl = curl_easy_init();
>
> if(curl) {
> curl_easy_setopt(curl, CURLOPT_URL,
"http://www.servere.com/file.htm");
> res = curl_easy_perform(curl);
> curl_easy_cleanup(curl);
> }
> return 0;
> }
>
>
> If some could tell me if theres a function to see if the page/file exists,
> or how I can add it, it would be really apreciated.
> Thks a lot
>
> _________________________________________________________________
> MSN Hotmail, o maior webmail do Brasil. http://www.hotmail.com
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
>

-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
Received on 2003-06-23