Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79365 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74363 invoked from network); 2 Dec 2014 00:10:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Dec 2014 00:10:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.176 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.176 mail-wi0-f176.google.com Received: from [209.85.212.176] ([209.85.212.176:51890] helo=mail-wi0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A6/27-32869-D830D745 for ; Mon, 01 Dec 2014 19:10:53 -0500 Received: by mail-wi0-f176.google.com with SMTP id ex7so26394410wid.9 for ; Mon, 01 Dec 2014 16:10:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type:subject:from:date:to :message-id; bh=Z7QFlfMUhRGIKGXTm1wtJ2zG6qusll8lycDAirdZ38w=; b=hL2zzwCpXPUsycWNbKxTnbxbHjTLjLRo5YV7gT+mEXWdoCCfcCV0xKgB5JR4INirm8 /Zguf1J1OTzNdnRuZ9r21WY0+Q4dT6H+o4T9R9ICL6iNfy9wU4ef7DOY/eX9AB7uUtY6 5luUgWeDd5X4Cs4gaiw7JYDhmjDSzDV4WIcEOPEWGYBv6y5HdhXS2CjiozlZ9LSd6Z1y xlxMzoJEQ34sVx2hgnrWbhMcQ9mb0TIsSEEtQPkstrGQiHtKEzefhkrDzaCRyWFvINGs gqC51/CueCskYD/6Y7hlTHQL0powcJ8lN12sT7dxrOMoiQeEaRmIiwGvMX9tzCwCNRiJ 0PMw== X-Received: by 10.194.187.164 with SMTP id ft4mr97031922wjc.76.1417479049394; Mon, 01 Dec 2014 16:10:49 -0800 (PST) Received: from [192.168.0.3] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by mx.google.com with ESMTPSA id ry19sm29625474wjb.3.2014.12.01.16.10.48 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Dec 2014 16:10:48 -0800 (PST) User-Agent: K-9 Mail for Android In-Reply-To: <547CEB74.9070807@ralphschindler.com> References: <547CEB74.9070807@ralphschindler.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Date: Tue, 02 Dec 2014 00:08:39 +0000 To: PHP Internals List Message-ID: Subject: Re: [PHP-DEV] $http_response_header From: rowan.collins@gmail.com (Rowan Collins) On 1 December 2014 22:28:04 GMT, Ralph Schindler 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