cURL / Mailing Lists / curl-library / Single Mail

curl-library

File Exists

From: Alex Salsinha <manobro87_at_hotmail.com>
Date: Thu, 19 Jun 2003 17:43:30 +0100

With this simple program, what i´m triyng to do, is if the file requested
doesn´t exist it does a printf() telling.

"The requested file doesn´t exist".

Where it´s the simple code:

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.server.com/file.htm");
    res = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
  return 0;
}

CODE####################

The res variable is always at 0, even if the file doens´t exits. If it
doens´t exists it shows the header 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>

Thks

_________________________________________________________________
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
Received on 2003-06-19