|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-04-16 16:25 UTC] 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"
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 15:00:01 2025 UTC |
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.