php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #44744 apache_response_headers() does not include duplicate headers
Submitted: 2008-04-16 16:25 UTC Modified: 2021-07-30 12:19 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: chsc at peytz dot dk Assigned: cmb (profile)
Status: Closed Package: Apache2 related
PHP Version: 5.2.5 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
45 + 14 = ?
Subscribe to this entry?

 
 [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"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-08 21:22 UTC] jani@php.net
-Package: Feature/Change Request +Package: Apache2 related
 [2012-09-09 12:13 UTC] 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…
 [2020-03-08 06:35 UTC] 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.
 [2021-07-30 12:19 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-07-30 12:19 UTC] cmb@php.net
Well, then this ticket can be closed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 08:01:28 2024 UTC