Re: [PHP-DEV] RFC: Server-Side Request and Response Objects (v2)

This is only part of a thread. view whole thread
  108529
February 13, 2020 06:45 ruudboon@php.net (Ruud Boon)
--Apple-Mail=_9C16F5E4-0018-4038-86FB-47C751F8EEE0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

Hi!

I really like this RFC.
> On 12 Feb 2020, at 23:46, Paul M. Jones <pmjones@pmjones.io> wrote: >=20 > Hi Allen & Robin, >=20 > Allen, you asked: >=20 >> On Feb 12, 2020, at 15:27, AllenJB lists@allenjb.me.uk> wrote: >>=20 >> This might be more a "future scope" thing, but I would like to see a = way to access the raw request body as part of this. Currently (as far as =
I know) the only way is to open/read php://input, which isn't = particularly intuitive in my opinion.
>=20 >=20 > Robin asked the same thing earlier: >=20 >> On Feb 11, 2020, at 08:24, Kingsquare.nl - Robin Speekenbrink = <robin@kingsquare.nl> wrote:
>>=20 >> What i haven't clearly seen in the RFC nor the interfaces of the = proposed objects: how will this handle PUT / php:://input / raw posted =
data? Or am i missing something?
>=20 > Answer: the php://input stream is accessible via the ServerRequest = $content property; see =
<https://github.com/pmjones/ext-request#content-related>. In the the RFC I see that $content will return php://input = <php://input> using file_get_contents on the fly. Can we add the = possibility to get a reference to the stream as well? This allows the = use of stream_copy_to_stream, mime_content_type etc without reading the = fill input to memory.
>=20 >=20 > -- > Paul M. Jones > pmjones@pmjones.io > http://paul-m-jones.com >=20 > Modernizing Legacy Applications in PHP > https://leanpub.com/mlaphp >=20 > Solving the N+1 Problem in PHP > https://leanpub.com/sn1php >=20 > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php Cheers,
Ruud --Apple-Mail=_9C16F5E4-0018-4038-86FB-47C751F8EEE0 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii Hi!

I really = like this RFC. 
On 12 Feb 2020, at 23:46, Paul M. Jones = <mailto:pmjones@pmjones.io" = class=3D"">pmjones@pmjones.io> wrote:

Hi = Allen & Robin,

Allen, you asked:

On Feb = 12, 2020, at 15:27, AllenJB <mailto:php.lists@allenjb.me.uk"= class=3D"">php.lists@allenjb.me.uk> wrote:

This might be more a "future scope" thing, but I would like = to see a way to access the raw request body as part of this. Currently = (as far as I know) the only way is to open/read php://input" = class=3D"">php://input, which isn't particularly intuitive in my = opinion.


Robin = asked the same thing earlier:

On Feb 11, 2020, at 08:24, http://Kingsquare.nl" class=3D"">Kingsquare.nl - Robin = Speekenbrink <mailto:robin@kingsquare.nl" = class=3D"">robin@kingsquare.nl> wrote:

What i haven't clearly seen in the RFC nor the interfaces of = the proposed objects: how will this handle PUT / php:://input / raw = posted data? Or am i missing something?

Answer: the php://input" class=3D"">php://input = stream is accessible via the ServerRequest $content property; see <https://github.com/pmjones/ext-request#content-related" = class=3D"">https://github.com/pmjones/ext-request#content-related>.=
In the the RFC I see that = $content will return  php://input" = class=3D"">php://input using file_get_contents on the fly. = Can we add the possibility to get a reference to the stream as well? = This allows the use of stream_copy_to_stream, mime_content_type etc = without reading the fill input to memory.



--
Paul M. Jones
mailto:pmjones@pmjones.io" class=3D"">pmjones@pmjones.io
http://paul-m-jones.com

Modernizing Legacy Applications in PHP
https://leanpub.com/mlaphp

Solving= the N+1 Problem in PHP
https://leanpub.com/sn1php

--
PHP Internals - PHP Runtime = Development Mailing List
To unsubscribe, visit: = http://www.php.net/unsub.php
Cheers,
Ruud
= --Apple-Mail=_9C16F5E4-0018-4038-86FB-47C751F8EEE0--
  108541
February 13, 2020 16:08 pmjones@pmjones.io ("Paul M. Jones")
Hi Ruud,


> On Feb 13, 2020, at 00:45, Ruud Boon <ruudboon@php.net> wrote: > > Hi! > > I really like this RFC.
Glad to hear it!
> In the the RFC I see that $content will return php://input using file_get_contents on the fly. Can we add the possibility to get a reference to the stream as well?
By "get a reference" I presume you mean "an open file handle" (a la `return fopen('php://input', 'rb')`). In which case: maybe? I can see where that would be useful for extremely large request bodies in a memory-constrained environment. But the question becomes: is that needed frequently-enough across a wide-enough range of PHP developers to warrant inclusion in this RFC? I don't recall seeing any userland implementation from my research provide such a thing. That makes me think it's a comparatively infrequent need. If many others disagree with that assessment, I'm happy to entertain the possibility of adding something like it to ServerRequest. -- Paul M. Jones pmjones@pmjones.io http://paul-m-jones.com Modernizing Legacy Applications in PHP https://leanpub.com/mlaphp Solving the N+1 Problem in PHP https://leanpub.com/sn1php