Re: $http_response_header
| From: | Ferenc Kovacs | Date: | Tue, 02 Dec 2014 10:28:20 +0000 |
| Subject: | Re: $http_response_header | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79376@lists.php.net to get a copy of this message | ||
On Tue, Dec 2, 2014 at 1:08 AM, Rowan Collins <rowan.collins@gmail.com>
wrote:
> On 1 December 2014 22:28:04 GMT, Ralph Schindler <ralph@ralphschindler.com>
> wrote:
> >Hi all,
> >
> >Many of you know from reading the subject line whats coming next! ;)
> >
> >In php, after we interact with HTTP streams (as a client), PHP conjures
> >
> >into local scope a variable with header information from the previous
> >request $http_response_header. Is this behavior something we want to
> >keep around into PHP 7? Or should we find a different/short-cut way to
> >get the information.
> >
> >Currently, the same information can be ascertained, but only if there
> >is
> >an open file handle and only through stream_get_meta_data($fh).
> >
> >It would be nice if there were an as-easy approach to getting data
> >without perhaps conjuring magic variables into the beloved local scope?
> >
> >Thoughts?
> >Ralph Schindler
> >
> >PS Also, do we have any other local-scope variables like this?
>
> Wow, I had no idea that existed; what an incredibly ugly implementation.
> Even the name is weird (why "header" singular when it contains an array of
> headers?)
>
> The only other local-scope variable listed next to it in the manual [1] is
> $php_errormsg, which has to be enabled with an ini setting.
>
> If the information is useful at all, then I guess a
> get_last_http_response_headers() function would be less magic - although
> that would presumably mean the data had to be stashed indefinitely in an
> internal global just in case it was asked for, rather than it naturally
> falling out of scope.
>
> We could just say that if you're using a shortcut like file_get_contents,
> you can't have it both ways and access metadata afterwards. It's just a
> pity ext/curl is so faithful to the underlying lib, and therefore so
> awkward to use for simple cases.
>
> [1]: http://php.net/manual/en/reserved.variables.php
>
>
+1 on introducing the get_last function, and I would also suggest adding a
new ini settings similarly to track_errors so we can discourage/deprecate
the usage of this feature before removing it.
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu