cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: File Exists

From: <RBramante_at_on.com>
Date: Thu, 19 Jun 2003 13:32:56 -0400
If the easy perform returns 0 (OK) then call curl_easy_getinfo with CURLINFO_HTTP_CODE and check to see if you got a 404.

 
-----curl-library-admin@lists.sourceforge.net wrote: -----

To: curl-library@lists.sourceforge.net
From: "Alex Salsinha" <manobro87@hotmail.com>
Sent by: curl-library-admin@lists.sourceforge.net
Date: 06/19/2003 12:43PM
Subject: File Exists

With this simple program, what im triyng to do, is if the file requested
doesnt exist it does a printf() telling.

"The requested file doesnt exist".

Where its 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 doenst exits. If it
doenst 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
NHS^隊X'u5T^بg ޖ^˥g^AاwEެ7ƭyԞgjvy8^.u'r " ׭P7ƭytz,)i0)޶޷ZޯuiReceived on 2003-06-19