xref: /PHP-7.3/sapi/cli/tests/bug61679.phpt (revision ded3d984)
1--TEST--
2Bug #61679 (Error on non-standard HTTP methods)
3--SKIPIF--
4<?php
5include "skipif.inc";
6?>
7--FILE--
8<?php
9include "php_cli_server.inc";
10php_cli_server_start(<<<'PHP'
11echo "This should never echo";
12PHP
13);
14
15list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
16$port = intval($port)?:80;
17
18$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
19if (!$fp) {
20  die("connect failed");
21}
22
23// Send a request with a fictitious request method,
24// I like smurfs, the smurf everything.
25if(fwrite($fp, <<<HEADER
26SMURF / HTTP/1.1
27Host: {$host}
28
29
30HEADER
31)) {
32    while (!feof($fp)) {
33        echo fgets($fp);
34        // Only echo the first line from the response,
35        // the rest is not interesting
36        break;
37    }
38}
39
40fclose($fp);
41?>
42--EXPECT--
43HTTP/1.1 501 Not Implemented
44