Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78836 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9385 invoked from network); 7 Nov 2014 05:16:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Nov 2014 05:16:37 -0000 Authentication-Results: pb1.pair.com header.from=theanomaly.is@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=theanomaly.is@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.51 as permitted sender) X-PHP-List-Original-Sender: theanomaly.is@gmail.com X-Host-Fingerprint: 74.125.82.51 mail-wg0-f51.google.com Received: from [74.125.82.51] ([74.125.82.51:49113] helo=mail-wg0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/B2-24315-4B55C545 for ; Fri, 07 Nov 2014 00:16:37 -0500 Received: by mail-wg0-f51.google.com with SMTP id l18so2741365wgh.24 for ; Thu, 06 Nov 2014 21:16:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=5CUeAY/6irMFshaOR7dWRl4BfvPry3QOp1z1oFElIus=; b=br9p26kIvV09Ff97+8gkwEsMn2P76XM4WLTRPp+QIlzJFTAdNvv82CNUnqbd0RAk+p tpOLgwnwNfPdaBGpPeS3rIXuDgJsz8NkBbyV454qsh0sC0dKGROu2K2Lg6/SGXRDDKh9 BXmjsOjGDIcdVb/a+/uSqwTd2P9y1vgSJS7MtY+D4nCPONxVHOHwG11koOqoaBFI4NIm tXF8KA/0qtTkiGfmR3B//y90/aOM4Vd5tX7xY/cGkEIFCjU7wyVR5CJsjJebuc03pJpb SOT4k9+hptIxStTs5+D3sip4rJN/9LgG46XjObJz4w0nJFzWyfyXsmJzlmd8xKiRCjeQ 7aAA== MIME-Version: 1.0 X-Received: by 10.180.14.165 with SMTP id q5mr1590321wic.0.1415337394230; Thu, 06 Nov 2014 21:16:34 -0800 (PST) Received: by 10.216.123.4 with HTTP; Thu, 6 Nov 2014 21:16:34 -0800 (PST) In-Reply-To: References: <1DDB6E05-3143-4A74-8B13-AF85222579BA@ajf.me> <468730E8-4C38-49A3-A61A-59E107313D79@ajf.me> <545C1823.8050404@sugarcrm.com> Date: Fri, 7 Nov 2014 00:16:34 -0500 Message-ID: To: Andrea Faulds Cc: Stas Malyshev , Patrick ALLAERT , PHP Internals Content-Type: multipart/alternative; boundary=f46d04138ae39edcea05073dea0e Subject: Re: [PHP-DEV] New Standardized HTTP Interface From: theanomaly.is@gmail.com (Sherif Ramadan) --f46d04138ae39edcea05073dea0e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, Nov 6, 2014 at 7:56 PM, Andrea Faulds wrote: > > > On 7 Nov 2014, at 00:53, Stas Malyshev wrote: > > > > Hi! > > > >> Again, I think you're oversimplifying the problem. For one, you don't > know > >> that the payload is JSON unless you check the Content-type header > yourself, > >> and you really shouldn't have to since PHP could easily do this for yo= u. > > > > Sure, PHP could easily do this, or any other one specific use case for > > you. What it can't do, however, is to do all 1000 use cases that modern > > REST application presents, automatically for you. What if you use XML > > and not JSON? What if you use both and determine which one it is by > > request URL suffix being .xml or .json? What if it instead is switched > > by query parameter? What if also it can be compressed, encrypted and > > wrapped in some MIME multipart message? Having all these complications > > handled in the core of PHP would be extremely hard, not because each of > > them is hard, but because there can be so many of them. And you'd run a > > big change of PHP still not matching your specific case exactly, or > > being behind times, because core can not evolve as quickly as userland > > does. That's why it's better done in extensions or user space - unless > > you can identify a case which covers a huge proportion of all cases - > > just like forms are for POST. For generic REST, I'm not sure there's > > such case, except for very generic API giving access to the basic > > request, its fields and supporting basic URL/MIME parsing. > > Even just parsing JSON isn=E2=80=99t as simple as it sounds. There are se= veral > things users might like to configure, several ways to parse JSON (objects > vs. arrays, big numbers as floats or strings, etc.), while for form-data > there=E2=80=99s only one way. > Well, in this case it will be parsed as an array since $_POST is naturally parsed as an array. Also, since $_POST/$_GET are typically always processed as strings it would only make sense to use big numbers as strings in the JSON parsing as well. I don't think this is the big issue. The bigger issue is do users typically find the population of $_POST more useful than just reading the input stream themselves and handling the JSON payload on their own. > > -- > Andrea Faulds > http://ajf.me/ > > > > > --f46d04138ae39edcea05073dea0e--