Hello,
I am writing an output caching module, and I am stuck on the issue of preserving the content type of output. When the php script runs I may call
header('Content-Type: text/javascript');
to indicate that the output is javascript.
Similarly, I might call
header('Content-Type: text/xml');
to indication that the output is xml.
It is easy to use output buffering (ob_start etc ..) to capture the actual content that is being output so that I can cache it for later. However how do I capture the headers that have been output by my script? If I must, I'll create a wrapper for the header function that saves the headers so that I can access them - but this would lose the genericity of the module.
Any tips appreciated.
Best regards
Steve Hannah
http://fas.sfu.ca/dataface
Capturing PHP headers
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Check out http://ca.php.net/headers-list - I have a feeling it's exactly what you're looking for. (PHP 5 only)
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Thanks jcart. This function appears to for getting the headers returned when you perform an HTTP request within your script. I'm looking for ways to obtain the headers that are sent from my current script. Kieran posted the headers_list function above which works for PHP 5. That man page doesn't show any PHP4 alternatives, however...
I use PHP 5 myself, but I like to find ways to maintain PHP 4 compatibility whereever possible for distribution purposes.
Best regards
Steve
I use PHP 5 myself, but I like to find ways to maintain PHP 4 compatibility whereever possible for distribution purposes.
Best regards
Steve
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA