curl-library
Re: File Exists
From: <RBramante_at_on.com>
Date: Thu, 19 Jun 2003 13:32:56 -0400
-----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 i´m triyng to do, is if the file requested
doesn´t exist it does a printf() telling.
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
N¬HS^µéšŠX¬²š'²ŠÞu¼ˆ5ëTÛ^žØ¨�g› ëÞ–Š^®À¨žË¥µ©í°œ¢g€œƒ^µAè²Ø§€ö«¶w«EçÞ¬7�‰ÆyÔž®÷«±gŒjv y8^™Š.ëuÐÊ'¶r ‰¦ŠË" ×P7�‰ÆyÓ�¨tz,¶)à†Ûiÿü0Â)Þ¶éÞ·úZ®ÙÞ¯ø§uìiReceived on 2003-06-19
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.
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 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
N¬HS^µéšŠX¬²š'²ŠÞu¼ˆ5ëTÛ^žØ¨�g› ëÞ–Š^®À¨žË¥µ©í°œ¢g€œƒ^µAè²Ø§€ö«¶w«EçÞ¬7�‰ÆyÔž®÷«±gŒjv y8^™Š.ëuÐÊ'¶r ‰¦ŠË" ×P7�‰ÆyÓ�¨tz,¶)à†Ûiÿü0Â)Þ¶éÞ·úZ®ÙÞ¯ø§uìiReceived on 2003-06-19