On Wednesday, 3 January 2024 at 14:34, Aleksander Machniak <a...@alec.pl> wrote:

> On 3.01.2024 14:41, Gina P. Banyard wrote:
>
> > Link: https://wiki.php.net/rfc/http-last-response-headers
>
>
> Wrong function name in the subject (should be "response" not "request")

Ah yes indeed, the RFC title is also incorrect.

> I don't think we need the clearing function. Do we?

Yes we do, because this is effectively global state whereas the variable is 
created in the *local* scope.

> I don't like that this is HTTP specific feature while we have other
> protocol wrappers. Here's a different approach. Use stream context with
> extended context parameters feature. Something like:
>
> $context = stream_context_create();
>
> $file = file_get_contents('http://www.example.com/', false, $context);
>
> $headers = stream_context_get_params($context)['response_headers'];
>
> Or something like that. I don't know.
>
> While on this I found out that we already have stream_get_meta_data()
> and `wrapper_data` there. So, maybe we should/could make it more unified.
>
> Maybe it should be mentioned in the RFC.

The whole point of this RFC is to be able to remove the local variable, 
requiring to drop to the stream layer, is the reason this got removed from the 
8.1 mass deprecation RFC.
That RFC also shows how this can be achieved currently, but it is way more 
cumbersome.

You cannot use any of the stream related functions if the request fails unless 
one ignores errors, which requires parsing every single response to know if it 
is valid or not instead of just checking for false.

Moreover, this means one cannot use file_get_contents().

As such, I am not going to change anything in the RFC as my objective is to get 
rid of the local variable creation in the long term.


Best regards,

Gina P. Banyard

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to