php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #34895 headers_list functionality regression
Submitted: 2005-10-17 18:39 UTC Modified: 2006-05-02 21:24 UTC
Votes:8
Avg. Score:4.1 ± 0.9
Reproduced:5 of 8 (62.5%)
Same Version:4 (80.0%)
Same OS:4 (80.0%)
From: alex at weej dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 5.0.5 OS: GNU Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alex at weej dot com
New email:
PHP Version: OS:

 

 [2005-10-17 18:39 UTC] alex at weej dot com
Description:
------------
The documented behaviour is exactly what I need for a project I am working on, but now the behaviour has changed (even though the docs haven't yet). :(

As far as I can see, there is no way to tell what headers PHP is sending and their values, now.

apache_response_headers() is /not/ a replacement, as it omits Content-Type (the most important header in my situation) and processes the headers PHP passes to it. I really don't want to resort to wrapper functions to maintain my own list. The documentation describes EXACTLY the functionality I want.

I am upset! :(

http://uk.php.net/manual/en/function.headers-list.php

Reproduce code:
---------------
<?php

/* setcookie() will add a response header on its own */
setcookie('foo', 'bar');

/* Define a custom response header
   This will be ignored by most clients */
header("X-Sample-Test: foo");

/* Specify plain text content in our response */
header('Content-type: text/plain');

/* What headers are going to be sent? */
var_dump(headers_list());

?>

Expected result:
----------------
array(4) {
  [0]=>
  string(29) "X-Powered-By: PHP/5.0.0"
  [1]=>
  string(19) "Set-Cookie: foo=bar"
  [2]=>
  string(18) "X-Sample-Test: foo"
  [3]=>
  string(24) "Content-type: text/plain"
}

Actual result:
--------------
array(4) {
  [0]=>
  string(12) "X-Powered-By"
  [1]=>
  string(10) "Set-Cookie"
  [2]=>
  string(13) "X-Sample-Test"
  [3]=>
  string(12) "Content-Type"
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-27 17:00 UTC] alex at weej dot com
The documentation has been updated now.

Is there going to be a replacement function in the very near future? I need this for a caching problem!
 [2006-01-24 18:06 UTC] alex at weej dot com
Still looking for a replacement function. Any ideas?
 [2006-01-30 20:43 UTC] lists at fairsky dot us
I've been looking through the CVS, and there has been only the very slightest change to headers_list since it was introduced, so I don't think it ever worked the way we want. I was going to try to patch my PHP source to make headers_list include the entire header, but so far it looks to me like it already should, so I'm obviously missing something.

If anyone knows enough to suggest a patch it would be useful to me even if it doesn't become official.
 [2006-03-07 13:19 UTC] virtuall at virtuall dot info
Thanks to orange at http://lv.php.net/apache_response_headers
I found it that apache_response_headers() does output all the headers after you call flush() (yes, even Content-type).
The dark side is that when headers and data are flushed, you can't send any more headers, but at least this works in some situations.
 [2006-05-02 21:24 UTC] bjori@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 20:01:35 2025 UTC