śr., 3 sty 2024 o 15:57 Gina P. Banyard <intern...@gpb.moe> napisał(a):

> On Wednesday, 3 January 2024 at 14:38, Michał Marcin Brzuchalski <
> michal.brzuchal...@gmail.com> wrote:
>
> Hi Gina,
>
> śr., 3 sty 2024 o 14:41 Gina P. Banyard <intern...@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?
>

My thinking was like passing as part of the context a placeholder by ref
where the headers of requests done in this context are to be populated.
This means instead of calling http_get_last_request_headers() as you
propose just read them from $response_headers array which got populated
during the HTTP call.
In general the same to what Aleksander asked.

Cheers

Reply via email to