Edit report at https://bugs.php.net/bug.php?id=53754&edit=1
ID: 53754 Comment by: wiltave at gmail dot com Reported by: pistole at rhp dot org Summary: Modify headers_list() to return an array of set headers in CLI SAPI Status: Open Type: Feature/Change Request Package: CGI/CLI related Operating System: Ubuntu Server 10.0 PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: It would be useful to write unit tests. Some codes need to send headers. Thank you. Previous Comments: ------------------------------------------------------------------------ [2011-01-14 22:45:54] pistole at rhp dot org 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 this bug report at https://bugs.php.net/bug.php?id=53754&edit=1