BACK
CGI
„Commen Gateway Interface”

dpfTVS supports the CGI/1.1 specifications. This chapter is not intended as a guide to program CGI scripts or even to understand what CGI is exactly for, the author assumes you are already familiar with that. It is just a summary of the features the CGI part of the dpfTVS supports and what values you can expect in the commenly availabe environment variables as well as the dpfTVS specific ones. In case you insist running dpfTVS in threading mode you should use an external mugi-cgi solution, else you might suffer from rather heavy speed loss under high load. The uri key-word is "cgi" (example: www.myserver.com/cgi/hallo.exe). Scripts that start with "nph-" (No Parse Header) won't go through the cgi own header parsing stage, but will still be processed by the servers main one. So it will happen that a date header field is added if not already there. This is also done to check for a forced "connection: close", to look for a cache or cache related pragma entry in the header. If it is a "200 ok" type of answer it will also still enforce a HEAD command or change the answer to "304" in case the appropriate header fields are there. Actually it will even change it to a 206 if possible and needed. dpfTVS supports keep-alive for http/1.0 and persistent connections for http/1.1. In order to achieve that, the server will add all header fields nescessary.

A script has to be marked as executable. If a user other than 0 was specified in the configuration file, this user has to have the appropriate rights to see the cgi work directory and to execute the script itself.

The needed re-routing of stdin and stdout is directly done with pipes. The server will only create a temp-file if the request was http/1.1 and contained a chunked body.

Exported http header fields
All header lines of an http request are passed on as environment variables in the form specified by the cgi/1.1 specification, excluding the requests main/first line.

CGI/1.1 Environment Variables
  • SCRIPT_NAME
    contains the name of the script, without the path, path information and query string
  • SERVER_SOFTWARE
    contains the server version string as specified in the configuration file
  • GATEWAY_INTERFACE
    always contains "CGI/1.1" as that's the supported CGI version
  • SERVER_PROTOCOL
    always contains "HTTP/1.1" as that's the supported http version
  • PATH_INFO
    contains path parts following the scripts name directly copied from the http request line
  • PATH_TRANSLATED
    contains the PATH_INFO reformatted to ascii
  • QUERY_STRING
    contains the query string without the leading '?' as given by the original request
  • SERVER_NAME
    contains the host name as specified by the original request
  • SERVER_PORT
    contains the server port the client connected to originally.
  • REQUEST_METHOD
    is the used request method as ascii text in uppercase letters, e.g. "GET"
  • REMOTE_ADDR
    contains the ip-address of the client in readable form, e.g. "192.168.0.3"
  • CONTENT_TYPE
    contains the content type of the body, if a body is there and one was specified in the request header
  • CONTENT_LENGTH
    contains the length of a following body in bytes, if there was a body.
  • REMOTE_USER
    in case you've also userdb running and the user is logged in it contains the "forum name" of the user
The other environment variables specified by cgi/1.1 are currently not supported

dpfTVS specific Environment Variables
  • TVS_REFERER
    contains the complete referer string as specified in the http request header
  • TVS_REFERER_HOST
    contains only the host name of the referer
  • TVS_SELFREFERER
    in case the referer host name is identical to the (virtual-)server name this variable contains "yes"
  • TVS_UID
    in case you also run the userdb and the user is logged in it contains the users index number of his database entry
  • TVS_isAdmin
    if the user is logged in, this contains a "yes" if his admin flag is set, else it contains a "no"
  • TVS_group0
    if the user is logged in, this contains his (forum)user-group setting as 8 digit hex value
  • TVS_group1
    if the user is logged in, this contains his (forum)moderator-group setting as 8 digit hex value
  • TVS_UM_socket
    this contains the tcp-port number of the userdb, if one is specified in the configuration file
  • TVS_UM_address
    this contains the ip-address of the userdb in readable form (e.g. "127.0.0.1"), if one is specified in the configuration file


Calling parameters
Following the CGI/1.1 specification, a query string that does not contain an ascii '=' will be translated into ascii and the white space seperated entries will be asigned as calling parameters. The unmodified string following the '?' will also be asigned to the query string environment variable.

BACK