Page 1 of 1
Obtaining headers on both Apache and IIS
Posted: Wed Dec 06, 2006 12:42 pm
by chrisv
Hey folks,
I'm hoping someone out there can point me to a function or set of functions that will retrieve header information for an incoming HTTP request, regardless of which web server is being used. I've already found the getallheaders() function, but it seems to only be supported under Apache -- I need to support IIS as well, hence my dilemma. Any help is appreciated!
Thanks,
chris
Posted: Wed Dec 06, 2006 12:56 pm
by feyd
Unless IIS can supply the information via COM, I'm pretty sure you're stuck.
What headers are you looking for?
Posted: Wed Dec 06, 2006 12:59 pm
by chrisv
Honestly, what I'm looking for is just a raw string that contains the HTTP header information. Doesn't even need to be parsed into an array.
The purpose is to assist in debugging potentially screwy conditions in the rest of the code, like a "catch all" error condition that just throws back the header information so the administrator might have a better idea of how to reproduce the problem. The server base we'll be installing this on is 50% Windows, 50% Apache -- hence the issue.
Oh well, thanks for confirming my suspicions!
chris
Posted: Wed Dec 06, 2006 1:03 pm
by feyd
Many of the request headers are often stored in $_ENV and $_SERVER. So you may want to dig into what your server's are providing in those before giving up. Sure, it's not raw information, but that's what server logs are for.

Posted: Wed Dec 06, 2006 1:29 pm
by chrisv
Great suggestion! I did a Google search based on this concept and came across this:
http://72.14.253.104/search?q=cache:WlU ... r=&strip=1
(It's a Google cache ... the main page is no longer available.)
It details out how Apache vs IIS tends to fill in the $_SERVER variable at least, which is a starting point.
Thanks for heading me in the right direction!
chris