1--TEST-- 2Bug #61977 test CLI web-server support for Mime Type File extensions mapping 3--SKIPIF-- 4<?php 5include "skipif.inc"; 6?> 7--FILE-- 8<?php 9include "php_cli_server.inc"; 10php_cli_server_start('<?php ?>', null); 11 12/* 13 * If a Mime Type is added in php_cli_server.c, add it to this array and update 14 * the EXPECTF section accordingly 15 */ 16$mimetypes = ['html', 'htm', 'svg', 'css', 'js', 'png', 'webm', 'ogv', 'ogg']; 17 18function test_mimetypes($mimetypes) { 19 foreach ($mimetypes as $mimetype) { 20 list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); 21 $port = intval($port) ? : 80; 22 $fp = fsockopen($host, $port, $errno, $errstr, 0.5); 23 if (!$fp) die('Connect failed'); 24 file_put_contents(__DIR__ . "/foo.{$mimetype}", ''); 25 $header = <<<HEADER 26GET /foo.{$mimetype} HTTP/1.1 27Host: {$host} 28 29 30HEADER; 31 if (fwrite($fp, $header)) { 32 while (!feof($fp)) { 33 $text = fgets($fp); 34 if (strncasecmp("Content-type:", $text, 13) == 0) { 35 echo "foo.{$mimetype} => ", $text; 36 } 37 } 38 @unlink(__DIR__ . "/foo.{$mimetype}"); 39 fclose($fp); 40 } 41 } 42} 43 44test_mimetypes($mimetypes); 45?> 46--EXPECTF-- 47foo.html => Content-Type: text/html; charset=UTF-8 48foo.htm => Content-Type: text/html; charset=UTF-8 49foo.svg => Content-Type: image/svg+xml 50foo.css => Content-Type: text/css; charset=UTF-8 51foo.js => Content-Type: application/javascript 52foo.png => Content-Type: image/png 53foo.webm => Content-Type: video/webm 54foo.ogv => Content-Type: video/ogg 55foo.ogg => Content-Type: audio/ogg 56