Annotation of embedaddon/php/sapi/cli/tests/bug61977.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Bug #61977 test CLI web-server support for Mime Type File extensions mapping
3: --SKIPIF--
4: <?php
5: include "skipif.inc";
6: ?>
7: --FILE--
8: <?php
9: include "php_cli_server.inc";
10: php_cli_server_start('<?php ?>', true);
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:
18: function 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
26: GET /foo.{$mimetype} HTTP/1.1
27: Host: {$host}
28:
29:
30: HEADER;
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:
44: test_mimetypes($mimetypes);
45: ?>
46: --EXPECTF--
47: foo.html => Content-Type: text/html; charset=UTF-8
48: foo.htm => Content-Type: text/html; charset=UTF-8
49: foo.svg => Content-Type: image/svg+xml
50: foo.css => Content-Type: text/css; charset=UTF-8
51: foo.js => Content-Type: text/javascript; charset=UTF-8
52: foo.png => Content-Type: image/png
53: foo.webm => Content-Type: video/webm
54: foo.ogv => Content-Type: video/ogg
55: foo.ogg => Content-Type: audio/ogg
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>