/
http_is_delete.phpt
84 lines (69 loc) · 1.62 KB
/
http_is_delete.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
--TEST--
Check isDelete
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
--FILE--
<?php
include 'php_cli_server.inc';
define('APPLICATION_PATH', __DIR__);
file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<<PHP
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {};
PHP
);
$controllerDir = APPLICATION_PATH . '/controllers';
if (!is_dir($controllerDir)) {
mkdir($controllerDir, 0777);
}
file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
var_dump(\$this->getRequest()->isDelete());
return false;
}
}
PHP
);
file_put_contents(APPLICATION_PATH . '/index.php', <<<PHP
<?php
define('APPLICATION_PATH', __DIR__);
\$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);
\$app = new Yaf_Application(\$config);
\$app->bootstrap()->run();
PHP
);
$handle = php_cli_server_start(null, "index.php", "-c php.ini");
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port)? :80;
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
die("connect failed");
}
$returnStr = '';
if(fwrite($fp, <<<HEADER
DELETE / HTTP/1.1
Host: {$host}
HEADER
)) {
while (!feof($fp)) {
$returnStr .= fgets($fp);
}
}
fclose($fp);
list($header, $body) = explode("\r\n\r\n", $returnStr);
echo $body;
--CLEAN--
<?php
unlink(__DIR__ . "index.php");
unlink(__DIR__ . "controllers/Index.php");
unlink(__DIR__ . 'Bootstrap.php');
rmdir(__DIR__ . 'controllers);
php_cli_server_stop($handle);
--EXPECTF--
bool(true)