rfc:http-last-response-headers
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:http-last-response-headers [2024/01/03 15:07] – Fix title girgias | rfc:http-last-response-headers [2024/02/29 16:42] (current) – Implemented girgias | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Add http_(get|clear)_last_response_headers() function ====== | ====== PHP RFC: Add http_(get|clear)_last_response_headers() function ====== | ||
- | * Version: 0.1 | + | * Version: 0.2 |
* Date: 2024-01-03 | * Date: 2024-01-03 | ||
* Author: Gina Peter Banyard < | * Author: Gina Peter Banyard < | ||
- | * Status: | + | * Status: |
* Target Version: PHP 8.4 | * Target Version: PHP 8.4 | ||
* Implementation: | * Implementation: | ||
Line 14: | Line 14: | ||
variable is magically created in the local scope whenever an HTTP request is performed through PHP's stream layer, | variable is magically created in the local scope whenever an HTTP request is performed through PHP's stream layer, | ||
i.e. when using the [[https:// | i.e. when using the [[https:// | ||
- | One such usage is using <php>file_get_content()</ | + | One such usage is using <php>file_get_contents()</ |
The [[https:// | The [[https:// | ||
variable will contain all the HTTP headers that were encountered during the request performed via the HTTP wrapper. | variable will contain all the HTTP headers that were encountered during the request performed via the HTTP wrapper. | ||
- | Because creating a variable in the local scope is a terrible way of returning additional information, | + | All other features using this operating principle, |
- | we have removed all other features using this operating principle, | + | such as [[https:// |
- | such as [[https:// | + | have been removed because creating a variable in the local scope is a terrible way of returning additional information. |
- | This variable was initially slated [[rfc: | + | This variable |
- | but due to the lack of convenient alternatives it was removed from the proposal. | + | but due to a lack of convenient alternatives, it was removed from the proposal |
- | Indeed, this variable is created and populated even if the HTTP request fails. | + | This variable is created and populated even if the HTTP request fails, |
- | Something | + | a behaviour |
- | stream context | + | stream context |
- | Which requires | + | Subsequently, |
+ | This is impractical and a better interface would be simply | ||
- | Thus, we propose adding functions similar to < | + | As a replacement, we propose adding functions similar to < |
[[https:// | [[https:// | ||
+ | |||
+ | ===== Motivation ===== | ||
+ | |||
+ | The primary motivation for adding this function, is to be able to remove the [[https:// | ||
+ | variable completely. To create this variable one needs to use the < | ||
+ | This is also the last usage of this engine function and its sibling function < | ||
+ | |||
+ | Moreover, this variable needs to be special cased in the optimizer/ | ||
+ | (via the < | ||
+ | Which means that any extension that would use this engine API would misbehave under opcache. | ||
+ | |||
+ | See the [[rfc: | ||
+ | section for an impact analysis of the removal of this feature. | ||
===== Proposal ===== | ===== Proposal ===== | ||
Line 40: | Line 53: | ||
* < | * < | ||
- | < | + | < |
[[https:// | [[https:// | ||
- | if a request via the HTTP wrapper is made and return the headers as an array even when the request fails. | + | if a request via the HTTP wrapper is made, and also return the headers as an array even when the request fails. |
- | If no request via the HTTP wrapper is made, or the previous | + | If no request via the HTTP wrapper is made, or the last headers have been cleared by calling |
< | < | ||
Line 52: | Line 65: | ||
there are no backward incompatible changes. | there are no backward incompatible changes. | ||
- | However, considering | + | Considering |
- | the last usage of the engine creating | + | this last usage of the capability to create |
- | We have found 65 usages in 30 projects across over 900 projects | + | We found only 65 usages in 30 projects across |
- | (composer packages, standalone open source projects, and private codebases) | + | (composer packages, standalone open source projects, and private codebases) |
Most of those usages stem from packages like Guzzle or OAuth client libraries. | Most of those usages stem from packages like Guzzle or OAuth client libraries. | ||
Line 68: | Line 81: | ||
</ | </ | ||
- | Considering the low usage of this feature, the possibility to write cross version compatible code, | + | Considering the sparse |
and the possible engine and optimizer simplifications, | and the possible engine and optimizer simplifications, | ||
- | it seems reasonable to be able to remove | + | it seems reasonable to slate this feature |
+ | |||
+ | ===== Rejected ideas ===== | ||
+ | |||
+ | One suggested idea was to provide those headers via a by-reference entry to the stream context. | ||
+ | This idea was rejected by us, and other members of the PHP Foundation, | ||
+ | as we wish to maintain stream contexts as a stateless configuration data structure passed to the stream. | ||
+ | |||
+ | This one-to-one feature replacement does not prevent the introduction of a more generic solution for other stream wrappers. | ||
+ | And this pair of new functions can always be slated for future deprecation and removal. | ||
===== Version ===== | ===== Version ===== | ||
Line 80: | Line 102: | ||
As per the voting RFC a yes/no vote with a 2/3 majority is needed for this proposal to be accepted. | As per the voting RFC a yes/no vote with a 2/3 majority is needed for this proposal to be accepted. | ||
- | Voting started on 2024-XX-XX and will end on 2024-XX-XX. | + | Voting started on 2024-01-29 and will end on 2024-02-14. |
<doodle title=" | <doodle title=" |
rfc/http-last-response-headers.1704294450.txt.gz · Last modified: 2024/01/03 15:07 by girgias