Hardware Reference
In-Depth Information
You should get something like this in your browser:
SCRIPT_FILENAME: /home/username/example.com/php/09_env.php
REMOTE_PORT: 52138
REDIRECT_URL: /php/09_env.php
GATEWAY_INTERFACE: CGI/1.1
SERVER_PROTOCOL: HTTP/1.1
REQUEST_METHOD: GET
QUERY_STRING:
REQUEST_URI: /php/09_env.php
SCRIPT_NAME: /php/09_env.php
ORIG_SCRIPT_FILENAME: /dh/cgi-system/php5.cgi
ORIG_PATH_INFO: /php/09_env.php
ORIG_PATH_TRANSLATED: /home/username/example.com/php/09_env.
php
ORIG_SCRIPT_NAME: /cgi-system/php5.cgi
PHP_SELF: /php/09_env.php
REQUEST_TIME: 1310417045
#CGI __utmz: 152494652.1295382826.13.2.utmccn=(referral)
|utmcsr=itp.nyu.edu|utmcct=/physcomp/studio/Spring2011/
TomIgoe|utmcmd=referral
__utma: 152494652.402968136.1288069605.1308754712.130876886
1.29
PATH: /usr/local/bin:/usr/bin:/bin
REDIRECT_HANDLER: php-cgi
REDIRECT_STATUS: 200
UNIQUE_ID: Thtgla3sqiUAAFdwW-UAAAAP
SCRIPT_URL: /php/09_env.php
SCRIPT_URI: http://www.example.com/php/09_env.php
HTTP_HOST: www.example.com
HTTP_CONNECTION: keep-alive
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac
OS X 10_6_8) AppleWebKit/534.30 (KHTML, like Gecko)
Chrome/12.0.742.112 Safari/534.30
HTTP_ACCEPT: text/html,application/xhtml+xml,application/
xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_ENCODING: gzip,deflate,sdch
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
HTTP_ACCEPT_CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.3
HTTP_COOKIE: __utmz=152494652.1295382826.13.2.utmccn=(refer
ral)|utmcsr=itp.nyu.edu|utmcct=/physcomp/studio/Spring2011/
TomIgoe|utmcmd=referral; __utma=152494652.402968136.12880696
05.1308754712.1308768861.29
SERVER_SIGNATURE:
SERVER_SOFTWARE: Apache
SERVER_NAME: www.example.com
SERVER_ADDR: 77.248.128.3
SERVER_PORT: 80
REMOTE_ADDR: 66.168.47.40
DOCUMENT_ROOT: /home/username/example.com
SERVER_ADMIN: webmaster@example.com
As you can see, there's a lot of information: the
web server's IP address, the client's IP address, the
browser type, the directory path to the script, and more.
You probably never knew you were giving up so much
information by making a simple HTTP request, and this is
only a small part of it! This is very useful when you want
to write server-side scripts that can respond to different
clients in different ways.
For example, HTTP_USER_AGENT tells you the name of
the software browser with which the client connected.
From that, you can determine whether if it's a mobile
phone, desktop, or something else, and serve appropriate
content for each. HTTP_ACCEPT_LANGUAGE tells you
the language in which the client would like the response.
When you combine REMOTE_ADDR with the IP geocoding
example to follow, you can even make a reasonable esti-
mation as to where the client is, assuming its request did
not come through a proxy.
 
Search WWH ::




Custom Search