Page 1 of 1

displaying raw HTTP headers

Posted: Fri May 21, 2004 9:54 am
by jimbodebnetwork
I'm a bit confused after looking at the dizzying assortment of superglobals and variable available as well as the numerous statements and functions that seem to do "sort of" what I want to do.

I want to build a very simple script that will echo back the raw HTTP request string sent to it by the calling client browser. It's mainly for debugging purposes. I figure I could capture a raw HTTP stream that I could then capture, alter, and submit to my site for testing.

For example, I'm want to see the HTTP request sent by PayPal's IPN to my notification page, notify.php. I'd like to capture the HTTP header and data intact, in string form, rather than just pulling out variables for processing.

I understand how to display the POST variables in $_POST as key=> value pairs. But, I want to see the entire request string entact, just as my page gets it.

I've found plenty of examples of building HTTP headers for *sending* to server. But, I haven't found any for capturing the HTTP stream.

Can someone please direct me as to which functions and variables to use to do this as easily as possible? I'm sure it's very simple to do. I'm just not sure how to go about it.

Thanks

Jimbo

[/mail_search]

Posted: Fri May 21, 2004 10:03 am
by jason
[php_man]getallheaders[/php_man]

Posted: Fri May 21, 2004 11:46 am
by launchcode
jim - for some reason PHP doesn't actually have the ability to echo out ALL of the HTTP headers unless you're running PHP as an Apache Compiled Module (in which case see the function Jason posted). Otherwise if you're not look at the superb PHP class file - Snoopy (snoopy.sourceforge.net).