xref: /PHP-7.1/sapi/cli/tests/bug71005.phpt (revision 7af945e2)
1--TEST--
2Bug #71005 (Segfault in php_cli_server_dispatch_router())
3--SKIPIF--
4<?php
5include "skipif.inc";
6?>
7--FILE--
8<?php
9
10$code = <<<'EOF'
11set_exception_handler(function () { echo 'goodbye'; });
12throw new Exception;
13EOF;
14
15include "php_cli_server.inc";
16php_cli_server_start($code);
17
18list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
19$port = intval($port) ?: 80;
20
21$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
22if (!$fp) {
23  die("connect failed");
24}
25
26if(fwrite($fp, <<<HEADER
27GET / HTTP/1.1
28Host: {$host}
29
30
31HEADER
32)) {
33	while (!feof($fp)) {
34		echo fgets($fp);
35	}
36}
37
38?>
39--EXPECTF--
40HTTP/1.1 200 OK
41Host: %s
42Date: %s
43Connection: close
44X-Powered-By: PHP/%s
45Content-type: text/html; charset=UTF-8
46
47goodbye
48