Web Development

Chapter 11. HTTP Variables

As HTTP servers and Web clients exchange data, the HTTP protocol sends a series of header fields containing information about the data being transferred over the Web. These header fields can, in turn, be passed to any program on your HTTP server. Because the information in these variables can be useful in your Panther Web application, Panther converts some of these header fields to global variables that can be accessed through JPL procedures or C functions.

An HTTP header field has a corresponding Panther HTTP variable. The Panther variable name begins with @cgi_ followed by the HTTP field name in lower case. The Panther HTTP variables are read-only and are automatically reset on each GET or POST of a Panther screen. Because Panther updates these variables automatically, copy their values elsewhere if you need them for a subsequent POST.

Common uses of the HTTP variables include:

For example, this JPL procedure builds a URL for a link with @cgi_server_name and @cgi_script_name.

proc build_link
// This procedure sets dynamic label's
// default_link property
home->default_link = "http:://" ## \
@cgi_server_name ## \
@cgi_script_name ## "/home.scr"
return 0

A Panther Gallery sample entitled HTTP Variables is accessible from the Web application server at:



The authentication method required to authenticate a user who desires access to a protected script.

The length of the data message if POST is used to submit data back to the server.

The MIME Content-Type of the data if POST is used to submit data back to the server. For Panther, this variable is set to:

The basic MIME types are listed in the following table:

MIME type Description


Binary data that can be executed or used by another application


Sound data


Image data


Encapsulated mail message


Multiple parts possibly consisting of many data types


Textual data


Video data

The version of the CGI specification to which this server complies in the following format:

A sample value would be:


A comma-separated list of MIME Content-Types that are acceptable to the client. They are listed in the following format:


You can use the contents of this variable to determine which image formats a browser can accept. For example, the following string indicates that the browser can display PNG, JPEG and GIF images:


A list of all the returned cookie values, separated by semi-colons. The cookie values are returned when the browser requests a document from the same HTTP server that set the cookie.

The URL of the document where the request originated. This can be a partial URL, in which case it is interpreted relative to the URL of the document being requested.

For Panther applications, this information is only useful on GET events. If the user enters a Panther application from elsewhere, for example from another website, this variable will specify that location, which can then be logged if desired.

Information about the browser software making the request. This variable identifies the browser type. Even though there is no standard format, this information usually appears in the following format:
software/version comments

You can determine the format for a particular browser only by experimentation. For example, the value sent from 32 bit Microsoft Internet Explorer 10.0 running on a 64 bit Windows 7 system might be:

Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)

Any extra path information found in the URL. Generally, this is the relative path to a resource.

Panther uses this information to determine which Panther screen to open. For the example, this variable would be:


The absolute path on the local system for a resource. This is done by pre-pending the server's document root directory, or DOCROOT, to the path specified in @cgi_path_info.

If the server's DOCROOT directory is /usr/local/htdocs, the variable would have the following value for the screen listed in the example:


A URL-encoded search string. This string is separated from the URL by a question mark. For the example, this variable would be:

For more information on URL encoding, refer to "Encoding Parameters in the URL."

The numeric IP address of the remote computer making the request. This is not necessarily the address of the client, but could be the address of the host machine where the browser is running.

The Internet domain name of the host machine making the request. This host machine is where the browser is running. If the domain name is unavailable, this field is left blank.

The remote user name retrieved by the server using the idntd identification daemon.

The authenticated name of the user.

The method associated with the request. For HTTP servers accessing Panther, this will be either GET or POST. The GET method is used when the user enters a specific URL or activates a hyperlink. The POST method is used when the user submits a form. Using this variable, you can choose which portions of your code to execute for each method.

The path and name of the CGI script being accessed, as it is referenced in a URL. Note that this is only the path that appears in the URL; it is not the actual, complete path of the CGI program. For the example, this value is: /cgi-bin/webdev

The Internet domain name of the HTTP server. If the domain name is not available, the numerical IP address is used. This is useful if the HTTP server is acting as home for multiple domains, and they each call the same Panther executable. In the example, the domain name is vbiz.com.

The port number receiving the browser request.

This is 123 in the example. Port numbers are useful if there are multiple servers running on the same machine, each calling the same Panther executable.

The name and version of the information protocol for the incoming request using the following format:

A sample value for this variable would be:


The name and version of the HTTP server software invoking the external program. The format is:

The following examples are typical values:

Apache/1.3.14 (Unix) (Red-Hat/Linux) PHP/4.0.3pl1