Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122100 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 21037 invoked from network); 3 Jan 2024 14:46:23 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jan 2024 14:46:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1704293214; bh=mol/IxttouJTOcsCTQ90leTAxAFsuTWljAr8/0ed2+g=; h=Date:To:From:Cc:Subject:In-Reply-To:References:From; b=EnkcWGKHjclzWYK94eSAoySfK1J4/uUSDP+MT0kBaJUp2lGNy4xRvCvJJKqAxQUry b9GaTl8f6VqHDm+vtLMXy45634QWYsUydWQH0/G4CORBt9gMYz6G1hiEI+WbsgiNp0 011ZyuSzdEzIROSDVa73f3AaYl8kW2pH1bwQBeBseSayu/Z2HDtON5BeKz2Nt9oULC KFIbw3gepgMvF+KWXSLvI9AxuUdw/7zrq0FELUn+vnW2resLwA58o2ttQMHbdsHRu1 JQeHpGpnP4V9Kmxfuvtlgq6yVecfQaleV+5YnQXg1CReTXQApInG2oVJSv36Pm81Oy g3mgneGAdu5dQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EAC9A180058 for ; Wed, 3 Jan 2024 06:46:51 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-4018.proton.ch (mail-4018.proton.ch [185.70.40.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 3 Jan 2024 06:46:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gpb.moe; s=protonmail; t=1704293177; x=1704552377; bh=mol/IxttouJTOcsCTQ90leTAxAFsuTWljAr8/0ed2+g=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=PEvrgh7IDntj2RtR+hHIfFee3Xd1u6iEN0UDGu9bggJ2N10EJztg37v7tfANNNsg2 /dF+0/OC+F7jcyfMzxyLBMwcd6A5WtX7Qe0ahFeSu7MoxoQxIz8hZrVZmdFG5/P9px Gw0u29e1SeFKOeTYwwHmvXfE0lgx41JhysmC6kITRVgfzcewoAGL8f73S+j9iRe1Jx R0X1fLmpM0KmM53wrEXbRkkQ7In62wU7N4M/T7ZVEq5uprp8GL9aonvvPNHbDafKKz ge/0X/Mwi7j8Fkf3Jvo7HpoCwsxNwQAG9AgBg+ZD4pCn2EOc8AoV9fjoE6sXjOqAQR aqfVeak3ZxxXg== Date: Wed, 03 Jan 2024 14:45:55 +0000 To: Aleksander Machniak Cc: internals@lists.php.net Message-ID: In-Reply-To: <648ce934-6203-4f17-8fbc-dc1f51c78e56@alec.pl> References: <648ce934-6203-4f17-8fbc-dc1f51c78e56@alec.pl> Feedback-ID: 96993444:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Add http_(get|clear)_last_request_headers() function From: internals@gpb.moe ("Gina P. Banyard") On Wednesday, 3 January 2024 at 14:34, Aleksander Machniak w= rote: > On 3.01.2024 14:41, Gina P. Banyard wrote: > > > Link: https://wiki.php.net/rfc/http-last-response-headers > > > Wrong function name in the subject (should be "response" not "request") Ah yes indeed, the RFC title is also incorrect. > I don't think we need the clearing function. Do we? Yes we do, because this is effectively global state whereas the variable is= created in the *local* scope. > I don't like that this is HTTP specific feature while we have other > protocol wrappers. Here's a different approach. Use stream context with > extended context parameters feature. Something like: > > $context =3D stream_context_create(); > > $file =3D file_get_contents('http://www.example.com/', false, $context); > > $headers =3D stream_context_get_params($context)['response_headers']; > > Or something like that. I don't know. > > While on this I found out that we already have stream_get_meta_data() > and `wrapper_data` there. So, maybe we should/could make it more unified. > > Maybe it should be mentioned in the RFC. The whole point of this RFC is to be able to remove the local variable, req= uiring to drop to the stream layer, is the reason this got removed from the= 8.1 mass deprecation RFC. That RFC also shows how this can be achieved currently, but it is way more = cumbersome. You cannot use any of the stream related functions if the request fails unl= ess one ignores errors, which requires parsing every single response to kno= w if it is valid or not instead of just checking for false. Moreover, this means one cannot use file_get_contents(). As such, I am not going to change anything in the RFC as my objective is to= get rid of the local variable creation in the long term. Best regards, Gina P. Banyard