Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63231 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45013 invoked from network); 24 Sep 2012 18:10:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Sep 2012 18:10:04 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 64.22.89.133 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 64.22.89.133 oxmail.registrar-servers.com Received: from [64.22.89.133] ([64.22.89.133:34572] helo=oxmail.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/D4-17579-BF1A0605 for ; Mon, 24 Sep 2012 14:10:03 -0400 Received: from [192.168.0.200] (5ad4bfa1.bb.sky.com [90.212.191.161]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by oxmail.registrar-servers.com (Postfix) with ESMTPSA id EEC1B758024; Mon, 24 Sep 2012 14:10:00 -0400 (EDT) Message-ID: <5060A1C5.8070701@ajf.me> Date: Mon, 24 Sep 2012 19:09:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: ivan.enderlin@hoa-project.net CC: internals@lists.php.net References: <505C4A06.6040304@hoa-project.net> In-Reply-To: <505C4A06.6040304@hoa-project.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] POST, content-type: application/json and json_decode From: ajf@ajf.me (Andrew Faulds) On 21/09/12 12:05, Ivan Enderlin @ Hoa wrote: > Hello, > > If PHP receives a HTTP request with the method POST and with the > header Content-Type: application/x-www-form-encoded, then, it > automatically parses the request body to populate an array in $_POST. > If the Content-Type is different (e.g. text/plain or > application/json), the request body is reachable by reading > php://input. Well, it is ok. > > But is there any plans to consider application/json by parsing the > request body and populate the result in $_POST (with the help of > json_decode() maybe)? I think perhaps that's the wrong approach. It's valid JSON to have a list literal at the top level as well, I think. Perhaps we should introduce a new $_JSON variable or some such thing? $_BODY? > > If so, I would like to propose a patch but I don't find in the source > code where request body is caugth and parsed (for POST). Any ideas? > Maybe a RFC would also be welcome to complete my suggestion? > > Thanks. > -- Andrew Faulds http://ajf.me/