xref: /PHP-7.1/sapi/cli/tests/bug67429.phpt (revision 113213f0)
1--TEST--
2FR #67429 (CLI server is missing some new HTTP response codes)
3--SKIPIF--
4<?php
5include "skipif.inc";
6?>
7--FILE--
8<?php
9include "php_cli_server.inc";
10
11// This creates a new server for each response code
12foreach ([308, 426] as $code) {
13  $proc_handle = php_cli_server_start(<<<PHP
14http_response_code($code);
15PHP
16  );
17
18  list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
19  $port = intval($port)?:80;
20
21  $fp = fsockopen($host, $port, $errno, $errstr, 0.5);
22  if (!$fp) {
23    die("connect failed");
24  }
25
26  if(fwrite($fp, <<<HEADER
27GET / HTTP/1.1
28
29
30HEADER
31  )) {
32      while (!feof($fp)) {
33          echo fgets($fp);
34      }
35  }
36
37  fclose($fp);
38  // Shutdown the servers or another server may not be able to start
39  // because of the this server still being bound to the port
40
41  php_cli_server_stop($proc_handle);
42}
43?>
44--EXPECTF--
45HTTP/1.1 308 Permanent Redirect
46Date: %s
47Connection: close
48X-Powered-By: %s
49Content-type: text/html; charset=UTF-8
50
51HTTP/1.1 426 Upgrade Required
52Date: %s
53Connection: close
54X-Powered-By: %s
55Content-type: text/html; charset=UTF-8
56