php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74438 $_REQUEST/$_POST not populated
Submitted: 2017-04-14 11:23 UTC Modified: 2017-04-14 11:31 UTC
From: ulimetic at hotmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.1.4 OS: Win 7 x64
Private report: No CVE-ID: None
 [2017-04-14 11:23 UTC] ulimetic at hotmail dot com
Description:
------------
From client in CURL:

$ch = curl_init();
$data = '{"test":"hello"}';
curl_setopt($ch, CURLOPT_URL, 'http://localhost');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'Content-Length: '.strlen($data)]);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$output = curl_exec($ch);
var_dump($output);
curl_close($ch);

From server
var_dump($_SERVER["CONTENT_TYPE"], $_REQUEST, $_POST);
//"string(16) "application/json" array(0) { } array(0) { } " 

But file_get_contents("php://input") is populated

Tied the same with an Ajax call and the result is identical







Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-14 11:31 UTC] daverandom@php.net
-Status: Open +Status: Not a bug
 [2017-04-14 11:31 UTC] daverandom@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

PHP does not decode JSON to populate POST, nor are there any plans to do so, nor does this particular make sense (JSON is not necessarily an associative array, and populating $_POST with data that is not an associative array would be surprising behaviour).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC