|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47495 headers_list returns an empty array
Submitted: 2009-02-24 15:02 UTC Modified: 2009-02-27 07:32 UTC
From: leha at inkin dot ru Assigned:
Status: Closed Package: iPlanet related
PHP Version: 5.2.8 OS: Linux 2.6.26
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:
Solve the problem:
34 + 40 = ?
Subscribe to this entry?

 [2009-02-24 15:02 UTC] leha at inkin dot ru
headers_list() returns an empty array. Though apache_response_headers() works

Using Sun Java System Web Server 7.0 Update 3 + PHP 5.2.8. The same problem
is with older SJSWS 7.0 U1 + PHP 5.2.1.

./configure --with-nsapi=/opt/webserver7u3 --with-openssl=/usr --with-
enable-dbase --enable-exif --enable-ftp --with-gd --with-ttf --with-t1lib=/usr --with-
enable-mbstring --with-libmbfl --with-mcrypt --with-mhash --with-ming --with-
with-libxml-dir --with-freetype-dir --with-xsl

Reproduce code:
header('Content-Type: text/html');

Expected result:
array(4) {
  string(23) "X-Powered-By: PHP/5.2.8"
  string(23) "Content-type: text/html"

Actual result:
array(0) {


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-24 15:06 UTC] leha at inkin dot ru
The whole php.ini:


magic_quotes_gpc = off
include_path = ".:/usr:/usr/share/php"
upload_max_filesize = 10M
 [2009-02-25 11:43 UTC]
Please try using this CVS snapshot:
For Windows:

As headers_list was a addition to PHP 5, not all SAPIs were aware of this and can handle it correctly. The PHP SAPI layer has two possibilities, to handle the headers:

- a callback that sets the header (NSAPI and other SAPIs use this, parse the header and set it in the webserver internal hashtable), SAPI will forget about the header after that.
- the headers are sent, when the response is committed, SAPI collects all headers in a SAPI-internal list.

The first solution had the problem, that the SAPIs manage the complete header addition and the PHP SAPI layer does not know anything about previously set headers (because the list of headers is not replicated). Calls to nsapi_response_headers (you should use this function, as apache_response_headers is only available in NSAPI for compatibility) retrieve the headers directly from the underlying webserver (you will also see headers, like "Connection" or other Keep-alive-headers, that were not set by PHP).

In NSAPI (and other SAPIs) headers_list() does not return anything, because the PHP-internal header list is always empty (because headers are managed by webserver only).

In PHP 5.3 a new SAPI callback that is also able to remove headers was implemented. This new SAPI-layer always caches the header list additionally to the webserver, so header_list will return the PHP-set headers here (but no lower-level headers by the webserver).

This bug will not be fixed in 5.2, can you please try PHP 5.3 snapshot and report if it works correctly there?
 [2009-02-25 18:51 UTC] leha at inkin dot ru
I built both 5.3.0beta1 and the latest snapshot with the very same configure as
5.2.8, but both didn't run with my SJSWS:

Sun Java System Web Server 7.0U3 B06/16/2008 09:44
failure: CORE2253: Error running Init function load-modules: dlsym for php5_init
failed (/opt/webserver7u3/bin/ undefined symbol: php5_init)

Still "--with-nsapi=..." presents. Perhaps it's my personal configuration installation
issue. I don't have time to investigate unstable releases, and I hope headers_list()
will work as you say with stable 5.3.
 [2009-02-25 19:59 UTC]
Please try using this CVS snapshot:
For Windows:

I fixed this also in 5.2 (was simple, I just kept the header in the internal sapi list), it may go into the shortly to be released PHP 5.2.9.

To your problem with 5.3:
I tried it out, it works here on Solaris 10 X64. This error message is mostly because of a missing library. PHP 5.3 has some more external dependencies (as I can see is additionally needed now on Sol).
 [2009-02-27 07:32 UTC]
This bug fix did not make it in PHP 5.2.9 (too late for the release), it is currently only in snapshot.

I will close this bug as fixed.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 06:01:29 2024 UTC