Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96170 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35450 invoked from network); 27 Sep 2016 08:14:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Sep 2016 08:14:01 -0000 Authentication-Results: pb1.pair.com header.from=pmjones88@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pmjones88@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.177 as permitted sender) X-PHP-List-Original-Sender: pmjones88@gmail.com X-Host-Fingerprint: 209.85.192.177 mail-pf0-f177.google.com Received: from [209.85.192.177] ([209.85.192.177:36510] helo=mail-pf0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9F/09-04248-74A2AE75 for ; Tue, 27 Sep 2016 04:14:00 -0400 Received: by mail-pf0-f177.google.com with SMTP id q2so3329642pfj.3 for ; Tue, 27 Sep 2016 01:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=QiXEiLzeGBhI2NnX/8XR/QeeqNGbDZtzCsKIBixhl1c=; b=VQAV/l3gSC3RaYODc/SNMMT6oQJJyResfMwDJKHhpy33JGhzkPCQn5pK9IZ8paTwDe 4Wm+GlkX86Mgv/ifmdTWH5F3RGmWX6R0Ews8hsKldjL2H8YPfwH30Fh6vb5wVacpH0X0 fUGunjTQGZsGB+4SghzSq3eysNtVfYKq4emDYzL/OxWvX7p1sq/8Yt77plMSKRFR+p32 XelwgxHDXre2jmkf2N9Joz2Y3nB7ta1JKq0RbXla9vxKQdsF4UB38LuyFN7IxuBSG+qx acbz02W3HV+2mYqeYPrXAg+3dArSgqTsEaARm8EDJvsmaep0HkgSrSCeBAeU3wBhvvht Q0Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=QiXEiLzeGBhI2NnX/8XR/QeeqNGbDZtzCsKIBixhl1c=; b=kP4EedxAmEQQGI/2Fq0tPkjCWrUUWlXkjt/Qvg340iRjzzzzWGx+sD985/bCdeZ0eu l/JTLVhE039qt3T3ikWmtbZmLGtX/X7aTOMk6LjW1SiSK1FueA3FAflueRQZN/riKUH0 G9vt6gEAj81vTrI2loFL9tWFBA+svY9CugO/BX4Eyr9lZExyg9PnbGVp09I+Q7ghJ3eU t2C41BZLjLltUK+n7jNsJHxd9tx75oyV5JySlMrNW850hmYBd+/5XvYvQCMDqs9iE51g S0GlTNAgSDemZp2K6aZBAzsW0PtzTqxjNodJa/xS/rSAOlNINO4G7x1Os5qCE95FoEv1 6rgQ== X-Gm-Message-State: AE9vXwP5Jmpq4DWH46Awm9zY0UI3cX2r/Ns1/fxMRUSa2Jl88x/l1wrGEG+/ABfpMn3ZXQ== X-Received: by 10.98.59.21 with SMTP id i21mr46529813pfa.78.1474964036358; Tue, 27 Sep 2016 01:13:56 -0700 (PDT) Received: from samurai.attlocal.net ([2602:306:bdf1:d380:b80b:3648:85ca:98df]) by smtp.gmail.com with ESMTPSA id n77sm2541929pfj.31.2016.09.27.01.13.55 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Sep 2016 01:13:55 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) In-Reply-To: Date: Tue, 27 Sep 2016 03:13:54 -0500 Content-Transfer-Encoding: quoted-printable Message-ID: <45813C0E-4D1A-4F0D-ABB1-B454AFAEC90E@gmail.com> References: To: PHP internals X-Mailer: Apple Mail (2.3124) Subject: Re: [PHP-DEV] Server-Side Request/Response Objects From: pmjones88@gmail.com (Paul Jones) Hi all, First, I want to reiterate that my initial desire was to submit this to = PECL, to give the project some exercise before bringing it to internals. = If someone here can nudge the PECL folks about my account request, = that'd be appreciated. Otherwise, I'm happy to continue the discussion = here. Now, on to the questions and criticisms. * * * > On Sep 26, 2016, at 16:10, Korvin Szanto = wrote: >=20 > Personally I would prefer complete HTTP message objects similar to = existing PSR-7 implementations be added perhaps alongside these simple = classes you've proposed. Mike Wallner notes his pecl_http work, which I think is good for = complete HTTP messages. * * * > On Sep 26, 2016, at 16:32, Rowan Collins = wrote: >=20 > This sounds like an interesting project, but I have a few questions. >=20 > First, the obvious one: why does this need to be an extension and/or = built into core? Are there reasons such as performance for implementing = this in C rather than PHP? Does it provide functionality that is hard to = implement in a userland library? The part that's hard to do in userland is public read-only properties = that cannot be subverted by child classes. As to building it into core, = I think it'd probably be better in PECL first, but my application there = has been ignored so far (though maybe I've not waited long enough). > You mention that it is not just an HTTP wrapper, but although you = mention researching other frameworks, I can't see any reference to PSR-7 = [http://www.php-fig.org/psr/psr-7/]. What do you see as the relationship = between your proposal and that standardisation effort? I did use it as a research subject, but I failed to include it in my = notes; I will add it. I was a sponsor on PSR-7, and I've worked with implementations since = before the PSR was finalized. I put together the Relay middleware = dispatcher, and some middleware pieces, and some applications, all using = PSR-7, so I'm relatively familiar with its ins and outs. However, I have come to think of it as "not having lived up to its = promise." That's not to denigrate MWOP, its lead author, whom I = encouraged throughout the PSR process. But the PSR-7 claim of = "immutability" turns out to be only partly true; instead, it is = quasi-immutable, and so it has the problems that come with both = mutability and immutability. There are some other problems, which if you = press me on I'll go into, but not eagerly and only with trepidation. This work steps back a little bit, to survey the actual implementations = of server-side requests and responses in userland, and bring together = their similarities (with a very little bit of refinement), instead of = building an entirely new and not-thoroughly-examined way of doing = things. > Regarding the design of the objects themselves, why is stdRequest = property-only, but stdResponse method-only? The asymmetry feels awkward = to me. Yeah, I get that. They use PHP itself as the example, where the = superglobals carry all the request-related information, and global = functions handle all the response-related activity. Part of the idea is = to make using StdRequest and StdResponse "feel" a bit more like using = the superglobals and global functions, while still corralling the = related information into its own space inside an object. * * * >=20 > On Sep 26, 2016, at 16:45, Michael Wallner wrote: >=20 > Did you include pecl/http in your research? I did, but I failed to note it. I will do so. > It looks like it covers most of that already, if not all. > I know you said *not* HTTP messages per se, but I don=E2=80=99t see a = lot of a difference. One difference regarding StdRequest is that everything is exposed as = read-only public properties. All of the frameworks/libraries I looked at = had equivalents of this: $value =3D $request->getPost($key, $default_value); That's to provide a default value if a particular $_POST key is not = available. However, under PHP 7, the ?? operator makes that kind of = method unnecessary: $value =3D $request->post[$key] ?? $default_value; Further, StdRequest includes things that are not part of HTTP messages = (e.g. all $_ENV values, and some $_SERVER values). The main difference regarding StdResponse is that instead of attempting = to mimic an HTTP Message model, it mimics PHP functionality, except = buffering the calls instead of sending them right away. (There are some = added convenience methods as well, drawn from the research subjects.) * * * > On Sep 26, 2016, at 16:52, Davey Shafik wrote: >=20 > Additionally to this, we need to start thinking about what it means to = move > away from simple request/response architectures. In the age of = WebSockets > and HTTP/2 multiplexing w/Server Push, the likelihood of multiple = responses > for one request, or even responses with no associated request, are = possible. I've spoken with Davey, and the summary seems to be that server-push is = possible, though in an impoverished way, via Link headers. Those can be = added with header(), which means they can be added with = StdResponse::setHeader(). As far as the rest, they are the subject of future work from Davey, = which I look forward to, and will be happy to incorporate as it becomes = available. (Davey, please correct me if I got that wrong.) > I'd rather look at this as the target for this kind of exploration and > implementation. To be clear, the StdRequest/StdResponse classes are not intended as = exploration; they are "summaries" of existing work in the field. --=20 Paul M. Jones http://paul-m-jones.com