Re: [RFC] Add http_(get|clear)_last_request_headers() function
| From: | Gina P. Banyard | Date: | Wed, 03 Jan 2024 14:56:59 +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-122101@lists.php.net to get a copy of this message | ||
On Wednesday, 3 January 2024 at 14:38, Michał Marcin Brzuchalski
<michal.brzuchalski@gmail.com> wrote:
> Hi Gina,
> śr., 3 sty 2024 o 14:41 Gina P. Banyard <internals@gpb.moe> napisał(a):
>
>> Hello internals,
>>
>> I would like to propose an RFC to add the functions http_get_last_request_headers() and
>> http_clear_last_request_headers() to PHP to replace the magic variable $http_response_header.
>>
>> Link: https://wiki.php.net/rfc/http-last-response-headers
>
> I was on the specific documentation page describing this feature Today and was thinking that it
> is inappropriate as well.
> But my thinking was whether it shouldn't be a part of a stream context instead, something
> like this:
>
> $response_headers;
> $context = stream_context_create([
> 'http' => ['response_headers' => &$response_headers]
> ]);
> $result =
> file_get_contents('http://example.com/submit.php', false,
> $context);
>
> This way by ref you get a specific HTTP wrapper running under the hood response headers instead
> of just the last one.
> Any thoughts about that?
I don't understand why the response should be part of the context of a stream.
Especially as I'm not aware of anything within the context that changes values after a request?
Best regards,
Gina P. Banyard