xref: /PHP-5.6/sapi/cli/tests/bug68745.phpt (revision 448ef30f)
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
30Connection: close
31X-Powered-By: %s
32Content-type: text/html; charset=UTF-8
33
34int(%d)
35