xref: /PHP-7.1/sapi/cli/tests/bug68745.phpt (revision f33c7b3e)
1--TEST--
2Bug #68745 (Invalid HTTP requests make web server segfault)
3--SKIPIF--
4<?php
5include "skipif.inc";
6?>
7--FILE--
8<?php
9include "php_cli_server.inc";
10php_cli_server_start('var_dump(count($_SERVER));', 'not-index.php');
11
12list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
13$port = intval($port)?:80;
14
15$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
16if (!$fp) {
17  die("connect failed");
18}
19
20if(fwrite($fp, "GET www.example.com:80 HTTP/1.1\r\n\r\n")) {
21    while (!feof($fp)) {
22        echo fgets($fp);
23    }
24}
25
26fclose($fp);
27?>
28--EXPECTF--
29HTTP/1.1 200 OK
30Date: %s
31Connection: close
32X-Powered-By: %s
33Content-type: text/html; charset=UTF-8
34
35int(%d)
36