Re: [RFC] Add http_(get|clear)_last_request_headers() function
| From: | Gina P. Banyard | Date: | Wed, 31 Jan 2024 00:34:04 +0000 |
| Subject: | Re: [RFC] Add http_(get|clear)_last_request_headers() function | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-122268@lists.php.net to get a copy of this message | ||
On Tuesday, 30 January 2024 at 08:48, Nicolas Grekas <nicolas.grekas+php@gmail.com> wrote:
>
> In Symfony's HttpClient, we use stream_get_meta_data($h)['wrapper_data'] to
> access headers, so there is already a way to get them using nothing but
> local scope.
>
> This makes me wonder why, in "rejected ideas", you wrote this?
>
> > One suggested idea was to provide those headers via a by-reference entry
> > to the stream context.
>
>
>
> Maybe we don't need anything but to promote what works already (this
> "wrapper_data" entry)?
The issue is this requires you to have a stream in the first place.
file_get_contents() doesn't return a stream, and if the request fails fopen(), by default,
returns false.
If you do have a stream, then yes stream_get_meta_data() is better, but the objective of this
addition is to replace the $http_request_header variable so that it can be removed.
This is a rather fringe feature, and thus I expect these functions to also be a fringe feature.
Best regards,
Gina P. Banyard