Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109005 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 32251 invoked from network); 13 Mar 2020 21:38:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Mar 2020 21:38:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1F08A1804FD for ; Fri, 13 Mar 2020 12:59:45 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 13 Mar 2020 12:59:44 -0700 (PDT) Received: by mail-qt1-f182.google.com with SMTP id g16so8646050qtp.9 for ; Fri, 13 Mar 2020 12:59:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=YgUSuQ5mn1rVtXK9JFMGCdGzIsDKTDjZeRMsDjtDmbM=; b=lqzcB3AaPLnm/Pglgg/iKwIl8gDl3gGzo+pQdR483TF3MALoVseeyMi3xgmTl2QLoI aIpZIEI9HizljgX4MzgZ9SZP4NFvB9P68qtWrJhXF08Mu2Z3aZ/4IsFePLPiNCD3cyoK QZ7++qGlIxlG2KIM82wS3x48rhkzbeHHC4jGYLawjj56NAx07FD5SjoEkc3LAcn1Do/A VE6OZy9pM/Yb/Z4scMbMeAYDDq3WEWAho6PpEFRN4XcLznAAjHrka17OcAIlKBWxx0ew c9o0w3bVbIKGRmumo6HC7RJ08CdbnppK4RnIRmdTLXckkeB3FvgARqtia0kArQUW9LLX ahoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=YgUSuQ5mn1rVtXK9JFMGCdGzIsDKTDjZeRMsDjtDmbM=; b=eoG6K9EavSXSjaamF1oYEVg4YfLdoN6OrNCdR8V7hkFLnXiLZu0eTcrdghWqYcIMRX WGLWbEQpguSZfZ5iHZE0n88nvzb4niwYY4okCTkiuENBeQ0D6cdT6OV+XWnnQHhmCpL1 wwcvmUB3bXjP1GI7OXmdEeVs9/Q4CoEcEIlgahgkje0NqihFUC8FtBFunTOCp35E9HXA WWn/La+KDnS7+PXg0HJHS4mW3jA+qrrEPFN7sjHVrf6aeEIOr0fYtdxxNSA3yUT+Q360 SCzTSwVX2Vh9dyOAu01tumwoEaaGJgS2yPVZonFFumnSu0aWJCFslUdrhSO+oh1N81fu iO6A== X-Gm-Message-State: ANhLgQ3WoRte6jVIqSLph/GqwxcVd/W775jgvuYgBva7ttzjPV47ieM7 UE82QHdwu8oaFcq6+yj1uq3YyA== X-Google-Smtp-Source: ADFU+vvTkymc1IllB6DTcZVYiw+1IdTECbfNGeZlfPUDXL5JWcoVeIUFRHR4gRSbZ7tEyoNlUeBoUg== X-Received: by 2002:ac8:7499:: with SMTP id v25mr14721808qtq.237.1584129582255; Fri, 13 Mar 2020 12:59:42 -0700 (PDT) Received: from ?IPv6:2601:c0:c680:5cc0:7893:a744:637c:91bf? ([2601:c0:c680:5cc0:7893:a744:637c:91bf]) by smtp.gmail.com with ESMTPSA id i13sm607285qke.56.2020.03.13.12.59.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Mar 2020 12:59:41 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) In-Reply-To: <71A325BA-3F53-4C9D-BE6A-D9A068A42AEA@koalephant.com> Date: Fri, 13 Mar 2020 15:59:39 -0400 Cc: "Paul M. Jones" , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <8A04B273-B298-4A2F-B0A5-8DF1F1D129A9@newclarity.net> References: <50BD013E-CF72-414C-BBC0-A7A2E45CBDDB@pmjones.io> <0B40E6E5-342F-4D81-9CAA-A0C0739A7718@pmjones.io> <102D234E-BC5D-42B2-ABC4-93980C1F76A4@pmjones.io> <71A325BA-3F53-4C9D-BE6A-D9A068A42AEA@koalephant.com> To: Stephen Reay X-Mailer: Apple Mail (2.3445.104.11) Subject: Re: [PHP-DEV] RFC: Server-Side Request and Response Objects (v2) From: mike@newclarity.net (Mike Schinkel) > On Mar 13, 2020, at 3:23 PM, Stephen Reay = wrote: >=20 > Hi Mike, >=20 > (I realise some of these points are possibly more addressed to Paul = than yourself, this is just where my brain went when I dug into what you = were mentioning) (after responding to your reply I think I was commenting on the RFC and = I think it is possible that you may have missed as few aspects of the = RFC such as a 'server' property on the ServerRequest variable. If that = is the case then we might be saying the same things. See = https://github.com/pmjones/ext-request#superglobal-related)=20 Yes, I should have made it more explicit. As author of the RFC I was = speaking to Paul in suggesting that if we are going to name the proposed = objects to be more specific to requests and response that we move the = server-specific aspects out and into their own object. =20 Otherwise I feel that dropping the "Server" from the name the object = clarifies one aspect and obfuscates another, albeit clarifying the = larger part. Better to make it all clear with another object named for = what it represents; server information. > I apologise if I=E2=80=99ve missed part of the discussion but what do = you mean by =E2=80=9Cmake sure it matches *exactly*. I was referencing your comments where my takeaway from reading what you = wrote is that you were asking that the naming match exactly what you = were viewing the objects to be doing, and that is to work with HTTP: "This extension and the classes it provides are inherently about = HTTP requests made to a php =E2=80=98server=E2=80=99, and the response = it sends back - and yet it=E2=80=99s called = Server{Request,Response,Buffer} etc=E2=80=A6. The =E2=80=9Cserver=E2=80=9D= part is superfluous in the context of a php web application, because = it=E2=80=99s all =E2=80=9Cserver=E2=80=9D side, and while uncommon = it=E2=80=99s not impossible to write *other* types of network server = using PHP." "TLDR: if you aren=E2=80=99t concerned about the concept of = php-initiated outgoing HTTP requests, I think = `HTTP{Request,Response,Buffer}` is quite clear in terms of naming. If = you wanted to be more explicit about their purpose (and/or prevent = possible confusion with either user land or potential future extensions = handling outgoing requests), `IncomingHTTPRequest` and = `OutgoingHTTPResponse` are very explicit, if a bit verbose." My point is simply that the server-specific aspects have nothing to do = with HTTP requests or HTTP responses, and if Paul was to rename his = classes to more closely align with HTTP requests and HTTP responses then = he should extract the server aspects out into their own class. > Do you mean how `->server` is listed as being a copy of the `$_SERVER` = super global? If so, can someone point me to the specific logic behind = that, given how many parts of it are already exposed via =E2=80=98dedicate= d=E2=80=99 properties of the proposed class? =46rom what I can see (and = I may have missed some) the parts of $_SERVER not exposed in some way = =E2=80=9Cdirectly=E2=80=9D on ServerRequest (nee CurrentRequest) are the = actual =E2=80=9Cserver=E2=80=9D parts: the `SERVER_*` keys, doc root, = PHP_SELF; and the =E2=80=98client=E2=80=99 parts: REMOTE_*; plus few = random stragglers like PATH_INFO, and for some reason = REQUEST_TIME[_FLOAT]? I don't think direct exposure is required; indirect exposure via an = array still means that aspects not related to HTTP requests and HTTP = responses are currently contained in the ServerRequest->server which to = me is okay if it is called "ServerRequest" but not okay if it is called = "HttpRequest," "WebRequest," "IncomingRequest," or "CurrentRequest." > Can those two things not be organised as a hash of those values, under = `server` and `client` (or `remote` if you want to keep the terminology - = yes I know it will be the originating TCP connection host not = necessarily the browser host)? As I said, I=E2=80=99ve missed some of = the discussion but I fail to see the benefit of a class to make all the = details of a web request and it=E2=80=99s response available=E2=80=A6. = And then just stick the existing superglobals in it untouched. Your response is confusing me. =20 You may actually be saying the same thing I am saying. I am referring = to the current state of the RFC where this would be possible: $request =3D new ServerRequest(); echo $request->server['HOME']; // Output the server's home directory. I am saying that it might be better to have those properties in a = different object: $info =3D new ServerInfo(); echo $info->home; // Output the server's home directory. print_r( $info->properties ); // Output everything found in $_SERVER = object > Things like the query params and body params make sense to be = accessible essentially (albeit with better names) as-is, because = they=E2=80=99re a hash of unknown shape by their very nature - but the = keys in _SERVER (barring http headers, which are already special cased) = are known, and have pretty clear definition of their meaning. Agreed. > Is the proposal really suggesting that a developer would still need to = do `if(!empty($request->server[=E2=80=98HTTPS=E2=80=99]) && = $request->server[=E2=80=98HTTPS=E2=80=99] !=3D=3D =E2=80=98off=E2=80=99) = {=E2=80=A6}` rather than just providing a `secureTransport` property (or = `https` if you prefer)?=20 Not sure. Paul needs to answer that. > One last point, regarding the =E2=80=98break out a server specific = class=E2=80=99 part. I don=E2=80=99t think it=E2=80=99s =E2=80=9Cwrong=E2=80= =9D to access these properties from something that is ostensibly related = to the =E2=80=9Ccurrent request=E2=80=9D, but it feels quite =E2=80=98wonk= y=E2=80=99 to me, the way it=E2=80=99s proposed with the full ->server = array just copied as-is, AND exposed via dedicated properties > Cheers Yes, I was saying that it is wrong *if* we are going to fine-tune the = name to a as closely as possible mirror what is contained within it. As = I said above having `server' in ServerRequest class does not both me but = it would bother me if `server' were in a HttpRequest class. Does this clarify? -Mike=