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