Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81720 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21254 invoked from network); 3 Feb 2015 15:08:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2015 15:08:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=ralph@ralphschindler.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ralph@ralphschindler.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain ralphschindler.com from 209.85.218.53 cause and error) X-PHP-List-Original-Sender: ralph@ralphschindler.com X-Host-Fingerprint: 209.85.218.53 mail-oi0-f53.google.com Received: from [209.85.218.53] ([209.85.218.53:59646] helo=mail-oi0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E4/11-20608-064E0D45 for ; Tue, 03 Feb 2015 10:08:17 -0500 Received: by mail-oi0-f53.google.com with SMTP id i138so49481647oig.12 for ; Tue, 03 Feb 2015 07:08:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=oVdQh/o+AFW950k82RylCEZbrIOsF5LADriIb63Gahg=; b=PPTj7U3EZ7TFy4fEFEh0LsSKr7NGqYi3/jhbQTVDgIjd3SpWXDQXqv1tB/Uw2bCJcU P8h7yoWkYQzRdKb6lZ/Pn1TmXIQxIa8zbhgEIDPmPNy7UIToo8aOpN006NSwNsLgQuih LkgVPSvAIHcXHBg527b6lZHQAfrzMAdNb0BgyIbMMCGcTJ0hclpZ+jv7//sodDGAYu6f fmIjiiKhqW3NQiPCxECmpywpK4SScNufsENDDF4HI4oQAk/Z137lLek6aucelLFw6PqO O9vhGDS1G0F3tGbqdr8TYMwatQDi7Wwq+WQ3KVNKy7er3hByuAO7CtDtqMuGzizDSSGZ O6Wg== X-Gm-Message-State: ALoCoQl/R/dfAQWmoE5ebL6AG4txK10nHmgRgbg+Dpy216gz9pEvWNNo2+SGsV/VrNhRGbdWZf9a X-Received: by 10.202.18.11 with SMTP id 11mr14846142ois.61.1422976094009; Tue, 03 Feb 2015 07:08:14 -0800 (PST) Received: from [172.16.1.4] (ip72-211-83-231.no.no.cox.net. [72.211.83.231]) by mx.google.com with ESMTPSA id t8sm4335596oib.4.2015.02.03.07.08.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Feb 2015 07:08:13 -0800 (PST) Message-ID: <54D0E45A.20109@ralphschindler.com> Date: Tue, 03 Feb 2015 09:08:10 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: internals@lists.php.net References: <547CEB74.9070807@ralphschindler.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] $http_response_header From: ralph@ralphschindler.com (Ralph Schindler) On 2/3/15 3:33 AM, Julien Pauli wrote: > On Mon, Feb 2, 2015 at 6:19 PM, Ferenc Kovacs wrote: > About $php_errormsg , we have error_get_last(). > About $http_response_headers, we have no replacement. Well, we sort of do. You can get header information from the http context stream metadata: $fh = fopen($urlPath, 'r', false, $context); $metadata = stream_get_meta_data($fh); $content = stream_get_contents($fh); fclose($fh); $metadata['wrapper_data'] will include the headers. From an ease-of-use standpoint, $http_reponse_header gives you immediate access to headers when the previous operation was a stream based HTTP request (via fopen, or even file_get_contents()). > Why not get rid of both ? > I mean, those variables magically appearing into your code are born from C, > where libc usually give access to errno and errstr variables (which are > often implemented as macros). We could, but it would be nice to add some kind of easy to use replacement for the "last stream operation", which essentially is the best/most common use case for $http_response_header after the fact that it is magically conjured into local scope. For example, right now, to get headers from a http stream request, its as ease as: $content = file_get_contents('http://php.net/'); var_dump($http_response_header); I think a nice replacement for that would be supporting (at least): $content = file_get_contents('http://php.net/'); $header = stream_get_meta_data()['wrapper_data']; By passing null to stream_get_meta_data(), it would use metadata from the last request made with streams (in the same way $http_response_header is allocated). Thats just a thought for that. I no other suggestion for the error stuff as I'd forgotten that even existed. -ralph