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 $host = PHP_CLI_SERVER_HOSTNAME; 21 $fp = php_cli_server_connect(); 22 if (!$fp) die('Connect failed'); 23 file_put_contents(__DIR__ . "/foo.{$mimetype}", ''); 24 $header = <<<HEADER 25GET /foo.{$mimetype} HTTP/1.1 26Host: {$host} 27 28 29HEADER; 30 if (fwrite($fp, $header)) { 31 while (!feof($fp)) { 32 $text = fgets($fp); 33 if (strncasecmp("Content-type:", $text, 13) == 0) { 34 echo "foo.{$mimetype} => ", $text; 35 } 36 } 37 @unlink(__DIR__ . "/foo.{$mimetype}"); 38 fclose($fp); 39 } 40 } 41} 42 43test_mimetypes($mimetypes); 44?> 45--EXPECT-- 46foo.html => Content-Type: text/html; charset=UTF-8 47foo.htm => Content-Type: text/html; charset=UTF-8 48foo.svg => Content-Type: image/svg+xml 49foo.css => Content-Type: text/css; charset=UTF-8 50foo.js => Content-Type: application/javascript 51foo.png => Content-Type: image/png 52foo.webm => Content-Type: video/webm 53foo.ogv => Content-Type: video/ogg 54foo.ogg => Content-Type: audio/ogg 55