xref: /PHP-7.0/sapi/cli/tests/bug70470.phpt (revision cd9d90f4)
1--TEST--
2Bug #70470 (Built-in server truncates headers spanning over TCP packets)
3--SKIPIF--
4<?php
5include "skipif.inc";
6?>
7--FILE--
8<?php
9include "php_cli_server.inc";
10php_cli_server_start("var_dump(getAllheaders());");
11
12$fp = fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT, $errno, $errmsg, 0.5);
13
14if (!$fp) {
15	die("connect failed: " . $errmsg);
16}
17
18fwrite($fp, "GET / HTTP/1.1\r\n");
19fwrite($fp, "Host: " . PHP_CLI_SERVER_HOSTNAME . "\r\n");
20fwrite($fp, "Content");
21fflush($fp);
22usleep(200000);
23fwrite($fp, "-Type: text/html; charset=UTF-8\r\n");
24fwrite($fp, "Connection: clo");
25fflush($fp);
26usleep(200000);
27fwrite($fp, "se\r\n\r\n");
28while (!feof($fp)) {
29	echo fgets($fp);
30}
31fclose($fp);
32?>
33--EXPECTF--
34HTTP/1.1 200 OK
35%a
36array(3) {
37  ["Host"]=>
38  string(9) "localhost"
39  ["Content-Type"]=>
40  string(24) "text/html; charset=UTF-8"
41  ["Connection"]=>
42  string(5) "close"
43}
44