Req #44744 [Opn->Csd]: apache_response_headers() does not include duplicate headers
| From: | cmb@php.net | Date: | Fri, 30 Jul 2021 12:19:53 +0000 |
| Subject: | Req #44744 [Opn->Csd]: apache_response_headers() does not include duplicate headers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-235477@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=44744&edit=1
ID: 44744
Updated by: cmb@php.net
Reported by: chsc at peytz dot dk
Summary: apache_response_headers() does not include duplicate
headers
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Apache2 related
Operating System: Linux
PHP Version: 5.2.5
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Well, then this ticket can be closed.
Previous Comments:
------------------------------------------------------------------------
[2020-03-08 06:35:27] cweiske@php.net
PHP 7.3 with Apache 2.4 (mod_php) does not exhibit this behavior: Duplicate headers get merged into
one ("X: Foo" and "X: Bar" appear in PHP as "X: Foo, Bar").
The problem still occurs with nginx/php-fpm, but that's a different problem.
------------------------------------------------------------------------
[2012-09-09 12:13:10] space at wechall dot net
Also in PHP 5.3.10â¦
i will test it on PHP 5.4 ASAPâ¦
Bug #25173 can be closed as duplicate of thisâ¦
------------------------------------------------------------------------
[2008-04-16 16:25:43] chsc at peytz dot dk
Description:
------------
When multiple response headers with the same name are set using header(..., false), only the last
value is returned by apache_response_headers().
apache_response_headers() returns an associative array, so it cannot have multiple entries for the
same header name. However, according to section 4.2 of RFC 2616, multiple headers with the same name
may be combined into one comma-separated header.
It MUST be possible to combine the multiple header fields into
one "field-name: field-value" pair, without changing the semantics
of the message, by appending each subsequent field-value to the
first, each separated by a comma.
I suggest that apache_response_headers() does this, i.e. combines multiple headers with comma.
Reproduce code:
---------------
header('Foo: 1');
header('Foo: 2', false);
header('Foo: 3', false);
var_dump(apache_response_headers());
Expected result:
----------------
array(2) {
["X-Powered-By"]=>
string(9) "PHP/5.2.5"
["Foo"]=>
string(1) "1,2,3"
}
Actual result:
--------------
array(2) {
["X-Powered-By"]=>
string(9) "PHP/5.2.5"
["Foo"]=>
string(1) "3"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=44744&edit=1