There are a few methods, but it depends on your software. If your using Apache, you can look at the following:
apache_request_headers()
getallheaders()
apache_response_headers()
for figuring out what you are going to send back.
I believe that all of those links above require that apache be configured as a module, and not as a cgi. You can check your current settings if you are unsure by using your phpinfo() and seeking Server API. If it says CGI, your out of luck on these functions.
There are however additional variables that you can use if your looking at the CGI installation. These exist both with the module and the CGI/CLI API's btw, and are all children of the $_ENV/$HTTP_ENV_VARS (envirornmental) superglobal:
HTTP_ACCEPT
HTTP_ACCEPT_ENCODING
HTTP_ACCEPT_LANGUAGE
HTTP_CONNECTION
HTTP_USER_AGENT
HTTP_REDIRECT_STATUS
HTTP_REMOTE_ADDR
HTTP_REMOTE_PORT
SERVER_PROTOCOL
and
REQUEST_METHOD
You may have more depending on your configurations, but chances are these are containing all the information you are looking for.
If your php version is >= 5.0.0, you can also use get_headers()
which I believe is API independant.
Hope that helps!
For more information please check,
http://www.codingforums.com/archive/index.php/t-69186.html