cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: file vs directory

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Mon, 3 Mar 2008 14:30:09 -0800

On Mon, Mar 03, 2008 at 01:42:26PM -0800, Ganesh Ragavan wrote:
> Is there a way to determine if the file I am requesting is a file or a
> directory?
>
> I would like to return an error if the user requests a directory instead of a
> file in libcurl. Is there any way I could do that?

Using HTTP? There's no 100% reliable way. You could use the PROPFIND command
on a WebDAV server to find out, or you could use some heuristics to guess on
a regular HTTP server (e.g. URLs ending in / are probably directories,
URLs redirecting to URLs ending in / too, or look at the resulting HTML and
guess). But most web servers treat requests to a directory as requests
to list the files in that directory without providing a consistent
machine-readable way to tell that that's what's been done.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2008-03-03