Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69321 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16153 invoked from network); 24 Sep 2013 16:12:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Sep 2013 16:12:15 -0000 Authentication-Results: pb1.pair.com header.from=rdlowrey@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rdlowrey@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.174 as permitted sender) X-PHP-List-Original-Sender: rdlowrey@gmail.com X-Host-Fingerprint: 209.85.215.174 mail-ea0-f174.google.com Received: from [209.85.215.174] ([209.85.215.174:59954] helo=mail-ea0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 49/00-15826-DD9B1425 for ; Tue, 24 Sep 2013 12:12:14 -0400 Received: by mail-ea0-f174.google.com with SMTP id z15so2610739ead.33 for ; Tue, 24 Sep 2013 09:12:11 -0700 (PDT) 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=IlSsQxjein2fCUs3RuD3cJbq/3fA40pSAd+rJrqx4w8=; b=WMKFVxPNwDSve0ivOhA0PWcqsJciIn1gqq9/VgUDosYRdsl8QO/7PhAheqDD9207Qa bA+nL92oRz8mfhpKjHLx3Vs5Kszl3JMKIowOxrZYwcNnXoKq0sIoxQK93BpjR7odlWKo K8/XjfZYasd4Z3MdmjsZtP0MCpYNjOlr3F60n894pswCBe9KqUpljehydGgnO0I/Gp08 BK+eav6MbH7KXo72gm5zjRFwmIZGDyYPMIkO1ul8MfwI5CbohqbNIdBGdCfwdIG1Moh8 eJofEhO3Odz0nVLLE/41MEY1wE5xsDj21MpmTtvRX5x7gopFDLIuuusc+AjtLiiFgJh4 JWUg== MIME-Version: 1.0 X-Received: by 10.14.172.133 with SMTP id t5mr46920297eel.35.1380039131007; Tue, 24 Sep 2013 09:12:11 -0700 (PDT) Received: by 10.223.199.129 with HTTP; Tue, 24 Sep 2013 09:12:10 -0700 (PDT) In-Reply-To: References: Date: Tue, 24 Sep 2013 12:12:10 -0400 Message-ID: To: catch.dave@gmail.com Cc: "internals@lists.php.net" , Ryan McCue , Tjerk Meesters Content-Type: multipart/alternative; boundary=047d7b603dcc2e310104e72366b3 Subject: Re: Parsing PUT data From: rdlowrey@gmail.com (Daniel Lowrey) --047d7b603dcc2e310104e72366b3 Content-Type: text/plain; charset=ISO-8859-1 Let me be clear: I'm not suggesting we should ignore useful functionality because of poor design decisions made in the past but I am saying that we should avoid compounding those mistakes by building on top of them. Would a $_PUT superglobal be helpful? Sure. But is it a good solution to underlying problem? Not really. > it's a common problem; I can agree with this -- PUT's use is widespread and adding support is probably sensible. That said, your other arguments don't hold much water: > I did originally. An inability on your part to write working code doesn't equate to "PHP should implement this for me" > it would a require very wide set of test cases to ensure it won't break in some random edge case The need for testing doesn't diminish if the parsing is implemented in C vs. PHP > Multipart support for PUT was literally the only issue I personally encountered when writing a public REST API in PHP. Are you sure you didn't need it for your RESTful PATCH requests too: http://tools.ietf.org/html/rfc5789 And what happened when you implemented Expect: 100-continue headers in your RESTful requests? Basically, if you're suggesting that adding $_PUT would solve all of PHP's problems with full HTTP protocol support then I can't agree. On Tue, Sep 24, 2013 at 11:42 AM, wrote: > Thanks Daniel. My thoughts on your response: > > Where does it stop? This is the problem I see with all the requests to > support for PUT similarly to POST. > > Right here with PUT. Providing a RESTful interface is *hugely* common and > $_PUT is the only one missing to complete REST. PUT is the glaringly > obvious one missing. > > You could easily write a parser in userland to accomplish the same thing. > > I did originally. But it became obvious that (a) it's a common problem; > (b) being non-trivial, it would a require very wide set of test cases to > ensure it won't break in some random edge case; and (c) the functionality > already exists for POST. > > Other languages (Ruby, for example) make REST very easy. Multipart support > for PUT was literally the only issue I personally encountered when writing > a public REST API in PHP. > > Dave. > > On 24/09/2013, at 7:59, Daniel Lowrey wrote: > > > In short, in order to provide a proper REST service that supports > multipart > > form data, we need someway to parse data sent via PUT (data is available > > via php://input, but it needs to be parsed). > > Multipart entity parsing is fairly straightforward. You could easily write > a parser in userland to accomplish the same thing. Unless you're doing a > very high volume of CRUD via PUT the performance hit of doing this in > userland should be negligible. > > That said, I think exposing a function to do this could be a useful > addition, and since PHP already has code to parse these entities for POST > requests it shouldn't be too much work to expose that via something like a > new mime_multipart_parse() function. It's not really a priority for me, but > you can probably find someone to work on this for you if you're not a C > person. > > The bigger issue here is that the superglobals are a leaky abstraction. > Any HTTP request method is allowed to have an entity body, so should we > also create $_PATCH and $_PUT and $_ZANZIBAR to handle less-frequently used > request methods? Where does it stop? This is the problem I see with all the > requests to support for PUT similarly to POST. PHP web SAPIs support 95% of > the HTTP use-cases people have, but the abstractions break down after that > and continuously bolting on support for individual scenarios beyond that > would be a mistake IMO. > > --047d7b603dcc2e310104e72366b3--