PHP  
 PHP_HEAD
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for sapi/cli/tests/bug61977.phpt ('Bug #61977 test CLI web-server support for Mime Type File extensions mapping')

Script

1: <?php
2:
include "php_cli_server.inc";
3:
php_cli_server_start('<?php ?>'true);
4:
5:
/*
6:  * If a Mime Type is added in php_cli_server.c, add it to this array and update
7:  * the EXPECTF section accordingly
8:  */
9:
$mimetypes = ['html''htm''svg''css''js''png''webm''ogv''ogg'];
10:
11: function 
test_mimetypes($mimetypes) {
12:     foreach (
$mimetypes as $mimetype) {
13:         list(
$host$port) = explode(':'PHP_CLI_SERVER_ADDRESS);
14:         
$port intval($port) ? : 80;
15:         
$fp   fsockopen($host$port$errno$errstr0.5);
16:         if (!
$fp) die('Connect failed');
17:         
file_put_contents(__DIR__ "/foo.{$mimetype}"'');
18:         
$header = <<<HEADER
19:
GET /foo.{$mimetype} HTTP/1.1
20: Host: 
{$host}
21:
22:
23:
HEADER;
24:         if (
fwrite($fp$header)) {
25:             while (!
feof($fp)) {
26:                 
$text fgets($fp);
27:                 if (
strncasecmp("Content-type:"$text13) == 0) {
28:                     echo 
"foo.{$mimetype} => "$text;
29:                 }
30:             }
31:             @
unlink(__DIR__ "/foo.{$mimetype}");
32:             
fclose($fp);
33:         }
34:     }
35: }
36:
37:
test_mimetypes($mimetypes);
38:
?>
39:

Expected

foo.html => Content-Type: text/html; charset=UTF-8
foo.htm => Content-Type: text/html; charset=UTF-8
foo.svg => Content-Type: image/svg+xml
foo.css => Content-Type: text/css; charset=UTF-8
foo.js => Content-Type: application/javascript
foo.png => Content-Type: image/png
foo.webm => Content-Type: video/webm
foo.ogv => Content-Type: video/ogg
foo.ogg => Content-Type: audio/ogg

Output

Warning: fsockopen(): unable to connect to localhost:8964 (Connection refused) in /var/php_gcov/PHP_HEAD/sapi/cli/tests/bug61977.php on line 15
Connect failed

Diff

001+ Warning: fsockopen(): unable to connect to localhost:8964 (Connection refused) in /var/php_gcov/PHP_HEAD/sapi/cli/tests/bug61977.php on line 15
002+ Connect failed
001- foo.html => Content-Type: text/html; charset=UTF-8
002- foo.htm => Content-Type: text/html; charset=UTF-8
003- foo.svg => Content-Type: image/svg+xml
004- foo.css => Content-Type: text/css; charset=UTF-8
005- foo.js => Content-Type: application/javascript
006- foo.png => Content-Type: image/png
007- foo.webm => Content-Type: video/webm
008- foo.ogv => Content-Type: video/ogg
009- foo.ogg => Content-Type: audio/ogg

 

Generated at Sat, 13 Dec 2014 06:16:29 +0000 (7 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.