Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108781 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 80410 invoked from network); 27 Feb 2020 11:25:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Feb 2020 11:25:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A614E180089 for ; Thu, 27 Feb 2020 01:43:39 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) (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 ; Thu, 27 Feb 2020 01:43:39 -0800 (PST) Received: by mail-io1-f54.google.com with SMTP id x1so2462927iop.7 for ; Thu, 27 Feb 2020 01:43:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=8x9gdmci3hbuHa4OfGyZCkJcj0T3oeDuy1KRnUWVU5A=; b=St8qf4yZpV75/3FG4LXLwgNybQVfVdAyYDQ0mTGsaEPwpWNFhIqUqky9VWp6XtPbfC S52JwBfN61FmCQm+GV+vgHLRd5D++O8grOj/PeBE7blNc3r2+kl/9OLM6UT6QmUwQHhp YI9VDJHriKQsDCJrCRghhs0R8HPqjCq2RrEODztALwayPDm4dBnEcKcTq+vcVFiiZxZm IaZlHdB8qiQLr/MlKG4bF3h7e0AV5Z4gKamW3ChNp9au1mzApMVkcTc36CB9ELUD6VlN LhEBVcQs0T0IbTwefNxtdwKPSrNV8REajGVQwFhGpMbwdfKFIMgUGQ/CYPMqVuJsGtd7 QlSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=8x9gdmci3hbuHa4OfGyZCkJcj0T3oeDuy1KRnUWVU5A=; b=HAOsgyPFy3G9V4yiGVJawsJ33q7zU1aal3lxjHlAvjaA68yL+zQEq8dRlKFTuf9aBE lT6+eAuQIejv+yIJKMr5Mje/S9Y8wpdDg03GPtxorX/mxVXgl1FpD5FhN7dQl8KnIXJi XP34+onz8d/mcQFyL0zcOt2MFyj7D0d0UpxhgFWI9nBuelgHTmZ3rOsNjC6IcvZ/qI4b hXphKL6ucsevQr+DsfHYNhr36prbVYET8CG6BEZ9DdV4GlpKd09fyHHUmj1A2FLY4bSu jXnNepcHRaBxZBXibbMae+hfVm5OIaRT3BGvOezTC5FCx/0MIIatBitj1RjgVgx9a2Sk x1sA== X-Gm-Message-State: APjAAAUFkxP5HfgdOfmJLH2HSaQG3KqufAQj6b7eFrerii9Lz5rcqfXr j0xexA00oJy/XIjKU6/NRnxLy5CCrWz87fFkgUWZHUEG X-Google-Smtp-Source: APXvYqwdQdaA0kqMfnFDzK//c+sIQ8amjlBQkdMqpo+2SrTB358rHTbO4M0y9AE+PfcAt0jQCQXqYC6IwJ5R83I47Qg= X-Received: by 2002:a5e:8612:: with SMTP id z18mr3709439ioj.206.1582796617482; Thu, 27 Feb 2020 01:43:37 -0800 (PST) MIME-Version: 1.0 References: <50BD013E-CF72-414C-BBC0-A7A2E45CBDDB@pmjones.io> <5904137.fSVIMsojiJ@mcmic-probook> <3DDBFBA4-8D3A-46C5-9A10-B093A5E2386B@pmjones.io> <54493258-B52E-442A-A11D-82E1D4C7DE5E@gmail.com> <8264F6CF-AD55-41E2-9F5A-DAE8942E2B79@pmjones.io> <1BF3D29A-04C6-4A82-9216-EAE991A38916@pmjones.io> <10388b3a-3402-a6dc-3837-b03d735edf46@gmail.com> <5ec7b4a7-508b-270b-916f-0504a116196c@gmail.com> <30112AFF-38F9-44D4-9D2F-03A32019764F@pmjones.io> <27F45990-E3AE-4A77-85EC-A2CA1EAC73E4@pmjones.io> In-Reply-To: <27F45990-E3AE-4A77-85EC-A2CA1EAC73E4@pmjones.io> Date: Thu, 27 Feb 2020 09:43:24 +0000 Message-ID: To: php internals Content-Type: multipart/alternative; boundary="00000000000023080c059f8b8eb7" Subject: Re: [PHP-DEV] RFC: Server-Side Request and Response Objects (v2) From: rowan.collins@gmail.com (Rowan Tommins) --00000000000023080c059f8b8eb7 Content-Type: text/plain; charset="UTF-8" On Thu, 27 Feb 2020 at 02:43, Paul M. Jones wrote: > > Recreating that functionality in userland is non-trivial, but is > essential for several use cases, e.g. an event-based server like ReactPHP, > or a test using a saved request body as a fixture. > > > > If both content types (application/x-www-form-urlencoded and > multipart/form-data) were handled, it would also mean that the relationship > $content -> $input would match the relationship php://input -> $_POST by > default, which seems consistent with the aim of matching existing behaviour. > > Yes, it would indeed. However, it strikes me that the thing to do here is > not to try and embed that behavior in ServerRequest; rather, it would be to > expose the existing functionality on its own, so that ReactPHP (and many > others!) can use them, instead of having to roll their own in userland (a > la < > https://github.com/reactphp/http/blob/master/src/Io/MultipartParser.php>). > Why not hope that ReactPHP and others will want to use this object, precisely because it avoids them having to roll their own implementations of things? If your concern is that the object should only wrap up features that are also available via some other mechanism, I'll point again at the $accept array, which AFAIK is a useful piece of parsing which is not available outside the proposed object's constructor. If anything, that's *more* special to this object, because what I'm proposing would directly parallel the existing behaviour of $_POST and $_FILES. If somebody really wanted to use the parser without the rest of the object, they could trivially wrap it in a function: function parse_multipart_form_data($content) { $request = new ServerRequest([], $content); return [ 'input' => $request->input, 'uploads' => $request->uploads ]; } The only downside I can see to adding it is complexity of implementation. But that's at best a reason to say "we'll hope to add this later" rather than "it would be better not to add it". Regards, -- Rowan Tommins [IMSoP] --00000000000023080c059f8b8eb7--