xref: /PHP-8.1/sapi/cli/tests/bug71005.phpt (revision 13274912)
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
18$host = PHP_CLI_SERVER_HOSTNAME;
19$fp = php_cli_server_connect();
20
21if(fwrite($fp, <<<HEADER
22GET / HTTP/1.1
23Host: {$host}
24
25
26HEADER
27)) {
28    while (!feof($fp)) {
29        echo fgets($fp);
30    }
31}
32
33?>
34--EXPECTF--
35HTTP/1.1 200 OK
36Host: %s
37Date: %s
38Connection: close
39X-Powered-By: PHP/%s
40Content-type: text/html; charset=UTF-8
41
42goodbye
43