cvs: php-master-web /scripts mirror-test

From: Date: Thu, 29 Mar 2007 15:53:03 +0000
Subject: cvs: php-master-web /scripts mirror-test
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-34974@lists.php.net to get a copy of this message
bjori Thu Mar 29 15:53:03 2007 UTC Modified files: /php-master-web/scripts mirror-test Log: Add test case for bug#26840 (faq.html.php is returned as HTML) Switch to PHP5 http://cvs.php.net/viewvc.cgi/php-master-web/scripts/mirror-test?r1=1.83&r2=1.84&diff_format=u Index: php-master-web/scripts/mirror-test diff -u php-master-web/scripts/mirror-test:1.83 php-master-web/scripts/mirror-test:1.84 --- php-master-web/scripts/mirror-test:1.83 Mon Mar 26 14:30:12 2007 +++ php-master-web/scripts/mirror-test Thu Mar 29 15:53:03 2007 @@ -1,7 +1,6 @@ -#!/usr/local/bin/php -q +#!/local/php5/bin/php -q <?php # vim: ft=php et -// This script is executed on master, the php5 binary can be found at -// /local/php5/bin/php +// This script is executed on master /* Check the state of each mirror site, and store the @@ -92,6 +91,14 @@ return FALSE; } +// Set default context options +$opts = array( + "user_agent" => "PHP.net Mirror Site check", + "max_redirects" => 0, + "timeout" => 5, +); +$context = stream_context_get_default(array("http" => $opts)); + // Get all mirror sites, and count the index of them foreach ($hosts as $index => $host) { @@ -193,6 +200,37 @@ $hosts[$index]['problem'] = "Apache manual alias in effect, see /mirroring.php."; continue; } + + // ------------------------------------------------------------------------- + // Third HTTP request, checking for known problems that has been hunting + // some mirrors for years (See bug#26840) + $url = "http://{$host['hostname']}/manual/en/faq.html.php"; + $headers = get_headers($url, 1); + if($headers == false) { + /* Possibly timed out, lets let it slight for now */ + continue; + } + + // No. This is not a joke. Some mirrors (*hint*tw.php.net*hint*) return + // "Content-type" for instance, not "Content-Type" + $headers = array_change_key_case($headers, CASE_LOWER); + + if(strpos($headers[0], "200") === false) { + $hosts[$index]['lastupdated'] = 0; + $hosts[$index]['problem'] = "Header weirdness. Pages named '.html.php' are returning wrong status headers\n"; + $hosts[$index]['problem'].= "Your mirror is currently returning '{$headers[0]}', not '200 OK'\n"; + $hosts[$index]['problem'].= "(The test was ran on $url)"; + var_dump($host['hostname'], $headers[0]); + continue; + } + if (strpos($headers["content-type"], "text/html") === false) { + $hosts[$index]['lastupdated'] = 0; + $hosts[$index]['problem'] = "Content-Type weirdness. Pages named '.html.php' are returning wrong Content-Type headers\n"; + $hosts[$index]['problem'].= "Should be returning 'text/html' but are returning '{$headers["Content-Type"]}'\n"; + $hosts[$index]['problem'].= "(The test was ran on $url)"; + var_dump($host['hostname'], $headers["content-type"]); + continue; + } } // Go through all mirror sites checked

« previous php.mirrors (#34974) next »