gsb <gs*@qwest.net> wrote:
[use HEAD to check for URL validity]
Ah, sorry.
I appreciate your response but it is a bit over me.
I've used sockets only in an example that I modified, and do not know how to
do a 'HEAD request.'
I can not find a reasonable example in the ref. I use.
It's quite simple, if the url you want to check is
http://hostname.tld/foo:
<?php
if($sock=fsockopen('hostname.tld',80))
{
fputs($sock, "HEAD /foo HTTP/1.0\r\n\r\n");
while(!feof($sock))
{
echo fgets($sock);
}
}
?>
This will echo 'HTTP/1.0 200 OK' if the url exists and might return
'HTTP/1.0 404 Requested URL not found' for a non existant page among
other headers.
You can disect an url with parse_url to get the hostname/port/path from
a URL. You might want to do HTTP/1.1 request (where a Host: header is
required (read RFC 2616 if you want to know more)).
But maybe you should take a look at PEAR, there appears to be an
HTTP::HTTP_Client class that prbably does something like this...
--
Daniel Tryba