ID:               34895
 Comment by:       virtuall at virtuall dot info
 Reported By:      alex at weej dot com
 Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: GNU Linux
 PHP Version:      5.0.5
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[2006-01-30 20:43:40] 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-01-24 18:06:27] alex at weej dot com

Still looking for a replacement function. Any ideas?

------------------------------------------------------------------------

[2005-10-27 17:00:09] 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!

------------------------------------------------------------------------

[2005-10-17 18:39:08] 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"
}


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=34895&edit=1

Reply via email to