At 20:48 25.03.2003, Jens Lehmann spoke out and said: --------------------[snip]-------------------- >> To actually check on the HTTP status codes you need to run your own, either >> using cURL, or by doing your own stuff using fsockopen(). > >I tried using fsockopen(), but still experience a problem, I want to use >the following script to retrieve both, the headers and the actual file:
You need to transmit the "Host:" header so the web server has a chance to know which virtual host you want to reach. Ideally you would also tell the server what type of content you can handle (see below). Also note that the "correct" line ending for MIME headers is always CRLF ("\r\n"): $hostname = 'www.example.com'; $file = '/index.php'; $ip = gethostbyname($hostname); $fp = fsockopen($ip, 80, &$errno, &$errstr); if ($fp) { fputs( $fp, "GET ".$file." HTTP/1.0\r\n" . "Host: $hostname\r\n" . "Accept: text/html\r\n" . "Accept: text/plain\r\n\r\n" ); $src = ''; while (!feof ($fp)) $src .= fgets($fp, 4096); fclose ($fp); } This will get you the whole page, including all headers. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php