290 likes | 312 Views
Environment Variables. Overview. Your CGI or ASP Programs may make use of a “Collection” of variables, variously called ENVIRONMENT or SERVER VARIABLES. Different variables may be set on different servers. Your server logs may be set to record these variables. To see actual examples:.
E N D
Overview • Your CGI or ASP Programs may make use of a “Collection” of variables, variously called ENVIRONMENT or SERVER VARIABLES. • Different variables may be set on different servers. • Your server logs may be set to record these variables.
To see actual examples: • http://parana.ecs.csus.edu/fall02/servervariables.asp • http://sequoia.ecs.csus.edu/~harville/cgi-bin/environment.cgi
CONTENT_LENGTH • The length in bytes of the returned document. • USE: Perhaps the programmer wants to limit the size of the response.
CONTENT_TYPE • The type of information returned. • Ex: text/html • USE: Perhaps the programmer wants to have different parts of the program activate depending on the content type.
DOCUMENT_ROOT • The main site directory. • USE: Setting up paths for dynamically generated URLs.
GATEWAY_INTERFACE • The CGI version number. • USE: Perhaps certain program features require a certain CGI version.
HTTP_ACCEPT • Media types the client accepts.
HTTP_ACCEPT_ENCODING Methods of compression the browser understands. HTTP_ACCEPT_ENCODING = gzip, deflate
HTTP_ACCEPT_LANGUAGE HTTP_ACCEPT_LANGUAGE = en-us • USE: Perhaps different files are to be served up depending on the language of the user.
HTTP_CONNECTION HTTP_CONNECTION = Keep-Alive Every request made requires that the server and client re-introduce each other. Keep-Alive is a switch that allows requests sent within a very short time to avoid this server-client bureaucracy.
HTTP_COOKIE • A list of cookies the particular site (or advertising group) has control over. • USE: Customer tracking, customization and other honorable or questionable activities.
HTTP_HOST The name of the machine on which the script resides. HTTP_HOST = parana
HTTP_REFERER • The page that requested the current document or program. • Note the correct misspelling. • Referrer would be more correct, but the mistake was made and not corrected. • USE: Redirection to a previous page.
HTTP_USER_AGENT • The client browser version. • Use: Customization or redirection based on browser type (and thus capabilities).
PATH_INFO • The current virtual path. PATH_INFO = /chat/servervariables.asp • Use: Recording a page name for redirection.
PATH_TRANSLATED • The full absolute path on the server. PATH_INFO = /chat/servervariables.asp PATH_TRANSLATED = C:\csc123\chat\servervariables.asp ALSO: APPL_PHYSICAL_PATH = C:\csc123\chat\
QUERY_STRING • This variable returns the query string: • ?example=Kevin%20Harville • USE: Using form or Querystring information.
REMOTE_ADDR • The remote IP making the request. • USE: Serving up unique pages based on the user. Companies have actually served different pages to their competitors than to their clients.
REMOTE_HOST • The remote hostname or IP of the requestor.
REQUEST_METHOD • I.e. GET or POST.
SCRIPT_NAME • The virtual path of the current script.
SERVER_NAME • Server hostname or IP
SERVER_PORT • Usually 80 • The “channel” incoming requests come in on.
SERVER_PROTOCOL SERVER_PROTOCOL = HTTP/1.1
SERVER_SOFTWARE SERVER_SOFTWARE = Microsoft-IIS/5.0
URL URL = /chat/servervariables.asp
Others • Numerous ones exist for SSL • HTTP_RAW and ALL_HTTP give long lists of the variables.
Summary • Server or Environment Variables are a useful means of site customization. • They allow for customers to be tracked, which may or may not be in the customer’s best interest. • The allow logging of information.