Page 1 of 1

Accessing raw client HTTP headers

Posted: Wed May 25, 2005 2:18 pm
by traherom
Is there anyway to access the raw HTTP headers (from PHP) the user sent to your webserer? A lot of the information can be retrieved in other ways, such as cookies through $_COOKIE, etc, but I'm creating a psuedo-proxy type thing and it would handy if I didn't have to go to all those different places.

Posted: Wed May 25, 2005 4:54 pm
by Skara

Posted: Wed May 25, 2005 7:34 pm
by traherom
headers_list() returns the headers to be sent to the client. Maybe (likely) my first post wasn't clear, but I'd like to be able to get the headers the client sent (to the server). IE, I'd like to be able to get the raw/numerically indexed

Code: Select all

GET /index.php HTTP/1.1
Host: texan.homeunix.net
Cookies: PHPSESSID=10293n12n3n49182312121212;
Other-header: blargaration
Etc: etera
the client sent to retrieve my document from the webserver.

Posted: Wed May 25, 2005 7:42 pm
by Skara
O.o
php.net wrote:headers_list -- Returns a list of response headers sent (or ready to send)
If that doesn't work, I don't have a clue.

Posted: Thu May 26, 2005 5:47 am
by traherom
The reason that headers_list() doesn't work is that it gives you the headers you have set to be sent/have been sent by header(). I would like the headers the user sent to me.

But, thanks. It may not be possible from PHP. :)

Posted: Thu May 26, 2005 8:04 am
by Roja
I'm going to cheat and give a roundabout answer. It can be done, and it looks like this: http://phpsniff.sourceforge.net/

Check their code (its relatively small and fairly well organized) for the methods.

Please let me know if I misunderstood the original question.