From: Operating system: Ubuntu Server 10.0 PHP version: 5.3.5 Package: CGI related Bug Type: Feature/Change Request Bug description:Modify headers_list() to return an array of set headers in CLI SAPI
Description: ------------ Calling headers_list() from the CLI version of PHP always returns an empty array, ignoring the results of previous calls to header(), despite the fact that they are already tracked internally. As some background, I'm attempting to write a pure PHP bootstrap development HTTP server to help programmers easily create new development environments and for lightweight standalone webapps that don't need a fully featured web-server to deploy. One of the things I'm trying to accomplish with this is to enable out of the box usage on various *nix distros and Mac OSX. The PHP-CGI SAPI is perfect for my project, but it isn't always installed by default (certainly not on OSX), so I'm attempting to make it work with the CLI version. I've managed to work around most of the limitations I've run up against, but this headers_list() always returning an empty array is a complete show-stopper. Without being able to retrieve the list, apps that set any kind of custom headers (including cookies), can never work correctly. I've attached a one-line patch to enable headers_list() to function in the CLI SAPI. Another (probably better) option would be to create an ini file setting to determine which behavior to exhibit. I'd be happy to do the dev work for that and submit the revised patch. Test script: --------------- #!/usr/bin/php <?php header('Location: asdf'); $list = headers_list(); var_dump($list); Expected result: ---------------- array(2) { [0]=> string(23) "X-Powered-By: PHP/5.3.5" [1]=> string(14) "Location: asdf" } Actual result: -------------- array(0) { } -- Edit bug report at http://bugs.php.net/bug.php?id=53754&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53754&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53754&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53754&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53754&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53754&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53754&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53754&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53754&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53754&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53754&r=support Expected behavior: http://bugs.php.net/fix.php?id=53754&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53754&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53754&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53754&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53754&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53754&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53754&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53754&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53754&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53754&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53754&r=mysqlcfg