rfc:http-last-response-headers

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:http-last-response-headers [2024/01/04 13:44] – Update wording girgiasrfc: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 <girgias@php.net>   * Author: Gina Peter Banyard <girgias@php.net>
-  * Status: Under Discussion+  * Status: Implemented in PHP 8.4: https://github.com/php/php-src/commit/47a199c8b43dbf84e66ff6b63f665541ab4eb1d0
   * Target Version: PHP 8.4   * Target Version: PHP 8.4
   * Implementation: [[https://github.com/php/php-src/pull/12500|https://github.com/php/php-src/pull/12500]]   * Implementation: [[https://github.com/php/php-src/pull/12500|https://github.com/php/php-src/pull/12500]]
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://www.php.net/manual/en/wrappers.http.php|HTTP wrapper]]. i.e. when using the [[https://www.php.net/manual/en/wrappers.http.php|HTTP wrapper]].
-One such usage is using <php>file_get_content()</php> to retrieve the content of a URL. +One such usage is using <php>file_get_contents()</php> to retrieve the content of a URL.
  
 The [[https://www.php.net/manual/en/reserved.variables.httpresponseheader.php|$http_response_header]] The [[https://www.php.net/manual/en/reserved.variables.httpresponseheader.php|$http_response_header]]
Line 34: Line 33:
 As a replacement, we propose adding functions similar to <php>error_get_last()</php>/<php>error_clear_last()</php> which replaced As a replacement, we propose adding functions similar to <php>error_get_last()</php>/<php>error_clear_last()</php> which replaced
 [[https://www.php.net/manual/en/reserved.variables.phperrormsg.php|$php_errormsg]]. [[https://www.php.net/manual/en/reserved.variables.phperrormsg.php|$php_errormsg]].
 +
 +===== Motivation =====
 +
 +The primary motivation for adding this function, is to be able to remove the [[https://www.php.net/manual/en/reserved.variables.httpresponseheader.php|$http_response_header]]
 +variable completely. To create this variable one needs to use the <php>zend_set_local_var_str()</php> engine function.
 +This is also the last usage of this engine function and its sibling function <php>zend_set_local_var()</php>.
 +
 +Moreover, this variable needs to be special cased in the optimizer/JIT
 +(via the <php>HTTP_RESPONSE_HEADER_ALIAS</php> enum case of <php>zend_ssa_alias_kind</php>).
 +Which means that any extension that would use this engine API would misbehave under opcache.
 +
 +See the [[rfc:http-last-response-headers#backward_incompatible_changes|Backward Incompatible Changes]]
 +section for an impact analysis of the removal of this feature.
  
 ===== Proposal ===== ===== Proposal =====
Line 72: Line 84:
 and the possible engine and optimizer simplifications, and the possible engine and optimizer simplifications,
 it seems reasonable to slate this feature for removal even without a deprecation notice if the need arises. it seems reasonable to slate this feature for removal even without a deprecation notice if the need arises.
 +
 +===== 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 81: 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="Accept Add http_(get|clear)_last_response_headers() function RFC?" auth="girgias" voteType="single" closed="true"> <doodle title="Accept Add http_(get|clear)_last_response_headers() function RFC?" auth="girgias" voteType="single" closed="true">
rfc/http-last-response-headers.1704375847.txt.gz · Last modified: 2024/01/04 13:44 by girgias