xref: /php-src/tests/basic/bug67198.phpt (revision 6ab4e330)
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(
37    "exit(file_get_contents('php://input'));", null,
38    ["-d", "enable_post_data_reading=Off"]);
39
40var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context));
41var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context));
42?>
43--EXPECT--
44string(4) "PASS"
45string(4) "PASS"
46