Accessing raw client HTTP headers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
traherom
Forum Newbie
Posts: 13
Joined: Tue Mar 15, 2005 6:43 am

Accessing raw client HTTP headers

Post 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.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

traherom
Forum Newbie
Posts: 13
Joined: Tue Mar 15, 2005 6:43 am

Post 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.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post 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.
traherom
Forum Newbie
Posts: 13
Joined: Tue Mar 15, 2005 6:43 am

Post 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. :)
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post 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.
Post Reply