Re: FW: looking for two remote functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/11/07, Myron Turner <turnermm02@xxxxxxx> wrote:


Tijnema ! wrote:
>
> I'm not very familiar with PERL, so will this work with remote files?
> As it seems that you are just reading from local hard drive...
>
> Tijnema
It has to be on the machine from which the pages are being served.


He was looking for remote functions....

There have been several workable suggestions for different
possibilities.  I think it would help if you gave the context for this.
Are these pages on your own web site?   Are you downloading pages from
third-party web sites using the browser?  Are you using the command line
to download pages from other servers?

Here is a script which will get the headers for any file you can
download from the web:

<?php
$fp = fsockopen("www.example.org", 80, $errno, $errstr, 30);
if (!$fp) {
   echo "$errstr ($errno)<br />\n";
} else {
   $out = "HEAD http://www.example.org/any_page.html / HTTP/1.1\r\n";
   $out .= "Host: www.example.org\r\n";
   $out .= "Connection: Close\r\n\r\n";

   fwrite($fp, $out);

   $header = "";
   while (!feof($fp)) {
       $header .=  fgets($fp, 256);
   }
   fclose($fp);
   echo $header;
}
?>

In response you will get the headers:

HTTP/1.1 200 OK
Date: Sun, 11 Mar 2007 14:57:54 GMT
Server: Apache/2.0.51 (Fedora)
Last-Modified: Sun, 11 Mar 2007 13:00:03 GMT
ETag: "10eb0036-4d1-3c2bbac0"
Accept-Ranges: bytes
Content-Length: 1233
Connection: close
Content-Type: text/plain; charset=UTF-8


This includes the content-length, which is what you want.  This script
will download only the headers.

You will not get a content-length headers for php files, since they are
in effect scripts and their length is not know in advance.  The same
holds true for files which contain SSI.


This is exactly what my script also did, get the content-length from the
header.
But i don't see what the actual problem is, there have been a lot of
solutions around here but they are all wrong?

Tijnema


_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux