mirror of
https://github.com/php/php-src.git
synced 2025-08-20 17:34:35 +02:00
update test for supported Mime Types checking
This commit is contained in:
parent
e5b1ebc082
commit
d813af0618
1 changed files with 30 additions and 132 deletions
|
@ -1,5 +1,5 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Bug #61977 (Need CLI web-server support for files with .htm & svg extensions)
|
Bug #61977 test CLI web-server support for Mime Type File extensions mapping
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
include "skipif.inc";
|
include "skipif.inc";
|
||||||
|
@ -8,145 +8,40 @@ include "skipif.inc";
|
||||||
<?php
|
<?php
|
||||||
include "php_cli_server.inc";
|
include "php_cli_server.inc";
|
||||||
php_cli_server_start('<?php ?>', true);
|
php_cli_server_start('<?php ?>', true);
|
||||||
$doc_root = __DIR__;
|
|
||||||
|
|
||||||
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
|
/*
|
||||||
$port = intval($port)?:80;
|
* If a Mime Type is added in php_cli_server.c, add it to this array and update
|
||||||
|
* the EXPECTF section accordingly
|
||||||
|
*/
|
||||||
|
$mimetypes = ['html', 'htm', 'svg', 'css', 'js', 'png', 'webm', 'ogv', 'ogg'];
|
||||||
|
|
||||||
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
|
function test_mimetypes($mimetypes) {
|
||||||
if (!$fp) {
|
foreach ($mimetypes as $mimetype) {
|
||||||
die("connect failed");
|
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
|
||||||
}
|
$port = intval($port) ? : 80;
|
||||||
|
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
|
||||||
file_put_contents($doc_root . '/foo.html', '');
|
if (!$fp) die('Connect failed');
|
||||||
if(fwrite($fp, <<<HEADER
|
file_put_contents(__DIR__ . "/foo.{$mimetype}", '');
|
||||||
GET /foo.html HTTP/1.1
|
$header = <<<HEADER
|
||||||
|
GET /foo.{$mimetype} HTTP/1.1
|
||||||
Host: {$host}
|
Host: {$host}
|
||||||
|
|
||||||
|
|
||||||
HEADER
|
HEADER;
|
||||||
)) {
|
if (fwrite($fp, $header)) {
|
||||||
while (!feof($fp)) {
|
while (!feof($fp)) {
|
||||||
$text = fgets($fp);
|
$text = fgets($fp);
|
||||||
if (strncasecmp("Content-type:", $text, 13) == 0) {
|
if (strncasecmp("Content-type:", $text, 13) == 0) {
|
||||||
echo "foo.html => ", $text;
|
echo "foo.{$mimetype} => ", $text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@unlink(__DIR__ . "/foo.{$mimetype}");
|
||||||
|
fclose($fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@unlink($doc_root . '/foo.html');
|
|
||||||
fclose($fp);
|
|
||||||
|
|
||||||
|
test_mimetypes($mimetypes);
|
||||||
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
|
|
||||||
if (!$fp) {
|
|
||||||
die("connect failed");
|
|
||||||
}
|
|
||||||
file_put_contents($doc_root . '/foo.htm', '');
|
|
||||||
if(fwrite($fp, <<<HEADER
|
|
||||||
GET /foo.htm HTTP/1.1
|
|
||||||
Host: {$host}
|
|
||||||
|
|
||||||
|
|
||||||
HEADER
|
|
||||||
)) {
|
|
||||||
while (!feof($fp)) {
|
|
||||||
$text = fgets($fp);
|
|
||||||
if (strncasecmp("Content-type:", $text, 13) == 0) {
|
|
||||||
echo "foo.htm => ", $text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@unlink($doc_root . '/foo.htm');
|
|
||||||
fclose($fp);
|
|
||||||
|
|
||||||
|
|
||||||
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
|
|
||||||
if (!$fp) {
|
|
||||||
die("connect failed");
|
|
||||||
}
|
|
||||||
file_put_contents($doc_root . '/foo.svg', '');
|
|
||||||
if(fwrite($fp, <<<HEADER
|
|
||||||
GET /foo.svg HTTP/1.1
|
|
||||||
Host: {$host}
|
|
||||||
|
|
||||||
|
|
||||||
HEADER
|
|
||||||
)) {
|
|
||||||
while (!feof($fp)) {
|
|
||||||
$text = fgets($fp);
|
|
||||||
if (strncasecmp("Content-type:", $text, 13) == 0) {
|
|
||||||
echo "foo.svg => ", $text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@unlink($doc_root . '/foo.svg');
|
|
||||||
fclose($fp);
|
|
||||||
|
|
||||||
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
|
|
||||||
if (!$fp) {
|
|
||||||
die("connect failed");
|
|
||||||
}
|
|
||||||
file_put_contents($doc_root . '/foo.css', '');
|
|
||||||
if(fwrite($fp, <<<HEADER
|
|
||||||
GET /foo.css HTTP/1.1
|
|
||||||
Host: {$host}
|
|
||||||
|
|
||||||
|
|
||||||
HEADER
|
|
||||||
)) {
|
|
||||||
while (!feof($fp)) {
|
|
||||||
$text = fgets($fp);
|
|
||||||
if (strncasecmp("Content-type:", $text, 13) == 0) {
|
|
||||||
echo "foo.css => ", $text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@unlink($doc_root . '/foo.css');
|
|
||||||
fclose($fp);
|
|
||||||
|
|
||||||
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
|
|
||||||
if (!$fp) {
|
|
||||||
die("connect failed");
|
|
||||||
}
|
|
||||||
file_put_contents($doc_root . '/foo.js', '');
|
|
||||||
if(fwrite($fp, <<<HEADER
|
|
||||||
GET /foo.js HTTP/1.1
|
|
||||||
Host: {$host}
|
|
||||||
|
|
||||||
|
|
||||||
HEADER
|
|
||||||
)) {
|
|
||||||
while (!feof($fp)) {
|
|
||||||
$text = fgets($fp);
|
|
||||||
if (strncasecmp("Content-type:", $text, 13) == 0) {
|
|
||||||
echo "foo.js => ", $text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@unlink($doc_root . '/foo.js');
|
|
||||||
fclose($fp);
|
|
||||||
|
|
||||||
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
|
|
||||||
if (!$fp) {
|
|
||||||
die("connect failed");
|
|
||||||
}
|
|
||||||
file_put_contents($doc_root . '/foo.png', '');
|
|
||||||
if(fwrite($fp, <<<HEADER
|
|
||||||
GET /foo.png HTTP/1.1
|
|
||||||
Host: {$host}
|
|
||||||
|
|
||||||
|
|
||||||
HEADER
|
|
||||||
)) {
|
|
||||||
while (!feof($fp)) {
|
|
||||||
$text = fgets($fp);
|
|
||||||
if (strncasecmp("Content-type:", $text, 13) == 0) {
|
|
||||||
echo "foo.png => ", $text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@unlink($doc_root . '/foo.png');
|
|
||||||
fclose($fp);
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
foo.html => Content-Type: text/html; charset=UTF-8
|
foo.html => Content-Type: text/html; charset=UTF-8
|
||||||
|
@ -155,3 +50,6 @@ foo.svg => Content-Type: image/svg+xml
|
||||||
foo.css => Content-Type: text/css; charset=UTF-8
|
foo.css => Content-Type: text/css; charset=UTF-8
|
||||||
foo.js => Content-Type: text/javascript; charset=UTF-8
|
foo.js => Content-Type: text/javascript; charset=UTF-8
|
||||||
foo.png => Content-Type: image/png
|
foo.png => Content-Type: image/png
|
||||||
|
foo.webm => Content-Type: video/webm
|
||||||
|
foo.ogv => Content-Type: video/ogg
|
||||||
|
foo.ogg => Content-Type: audio/ogg
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue