xref: /PHP-7.4/tests/basic/bug67198.phpt (revision 17f7fb76)
1--TEST--
2php://input is empty when enable_post_data_reading=Off
3--INI--
4allow_url_fopen=1
5--CONFLICTS--
6server
7--SKIPIF--
8<?php
9include __DIR__."/../../sapi/cli/tests/skipif.inc";
10?>
11--FILE--
12<?php
13require __DIR__."/../../sapi/cli/tests/php_cli_server.inc";
14
15$code =
16<<<'FL'
17 if(!ini_get('enable_post_data_reading')){
18  if($_SERVER['REQUEST_METHOD']=='POST'){
19   exit(file_get_contents('php://input'));
20  }
21 }else{
22  exit('Please SET php.ini: enable_post_data_reading = Off');
23 }
24FL;
25
26$postdata = "PASS";
27
28$opts = array('http' =>
29    array(
30        'method'  => 'POST',
31        'header'  => 'Content-type: application/x-www-form-urlencoded',
32        'content' => $postdata
33    )
34);
35
36$context  = stream_context_create($opts);
37
38php_cli_server_start(
39    "exit(file_get_contents('php://input'));", null,
40    ["-d", "enable_post_data_reading=Off"]);
41
42var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context));
43var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context));
44--EXPECT--
45string(4) "PASS"
46string(4) "PASS"
47