Web Development |
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 A Panther Gallery sample entitled HTTP Variables is accessible from the Web application server at:
@cgi_server_name
and @cgi_script_name
.
proc build_link
// This procedure sets dynamic label's
// default_link propertyhome->default_link = "http:://" ## \
@cgi_server_name ## \
@cgi_script_name ## "/home.scr"
return 0http://server-name/cgi-bin/jwsamp/main
Definitions |
@cgi_auth_type
@cgi_content_length
POST
is used to submit data back to the server.
@cgi_content_type
POST
is used to submit data back to the server. For Panther, this variable is set to:
application/x-www-form-urlencoded
The basic MIME types are listed in the following table:
@cgi_gateway_interface
CGI/version-number
A sample value would be:
CGI/1.1
@cgi_http_accept
type/subtype
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:
image/png,image/jpeg,image/gif
@cgi_http_cookie
@cgi_http_referer
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.
@cgi_http_user_agent
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)
@cgi_path_info
Panther uses this information to determine which Panther screen to open. For the example, this variable would be:
/vbiz/vidlist.scr
@cgi_path_translated
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:
/usr/local/htdocs/vbiz/vidlist.scr
@cgi_query_string
start=top
For more information on URL encoding, refer to "Encoding Parameters in the URL."
@cgi_remote_addr
@cgi_remote_host
@cgi_remote_ident
@cgi_remote_user
@cgi_request_method
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.
@cgi_script_name
/cgi-bin/webdev
@cgi_server_name
vbiz.com
.
@cgi_server_port
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.
@cgi_server_protocol
protocol/version-number
A sample value for this variable would be:
HTTP/1.0
@cgi_server_software
software-name/version
The following examples are typical values:
Apache/1.3.14 (Unix) (Red-Hat/Linux) PHP/4.0.3pl1
Microsoft-IIS/7.5