This page describes how weborf implements the rfc3875: cgi .
Every difference existing from the rfc in the real implementation must be considered a bug and can be reported.

CGI script

Weborf will associate an executable file to each file extension (for example .cgi) and will execute that binary file, that will have to handle the execution of the appropriate script, using some environmental variables.

If you want to execute .cgi files, the default installation provides a wrapper for them, so it is possible to execute:

weborf -c .cgi,/usr/lib/cgi-bin/weborf_cgi_wrapper

The wrapper will just execute the cgi script, it will not provide any error reporting.


Weborf will attempt to terminate the script after SCRPT_TIMEOUT seconds, as defined in configuration.
Weborf will send to the client any output that the script generated before terminating, even if it wasn't the full page.
So every write operation of file or database should be done in atomic way.


Php has a timeout setting in php.ini but looks like php-cgi ignores it. So don't rely on this setting.

Enviromental variables

Weborf will delete all the environmental variables and set only the following ones, so export used before executing weborf will have no effect.

  • SERVER_PORT: Port the client connected to.
  • SERVER_SIGNATURE: Version and name of the webserver
  • SERVER_SOFTWARE: Same as above
  • GATEWAY_INTERFACE: Tells which version of CGI protocol is in use. Always set to “CGI/1.1”
  • REDIRECT_STATUS: This variable is required to make php-cgi work. It is set to “Ciao”. I know there is no logic in that.
  • REMOTE_ADDR: IP address of the client. Depending on how weborf was compiled it can be an IPv4 or IPv6
  • SCRIPT_NAME: Name of the script without complete path
  • SCRIPT_FILENAME: Script to execute. It is the full local path of the requested page
  • CONTENT_LENGTH: If REQUEST_METHOD is “POST”, this var will tell how long is the data
  • CONTENT_TYPE: This will be set if CONTENT_LENGTH is set and will tell the type of the post data (form, file)
  • SERVER_PROTOCOL: Will contain the version of the http protocol used in the request
  • REQUEST_URI: Will contain the full URI of the HTTP request: page and query, separated by ? If there was no query, the ? will not be present
  • QUERY_STRING: Will contain all the things after the ? in the url
  • DOCUMENT_ROOT: is the basedir
  • SERVER_NAME: name of the server for the client, as defined in Host header in http request
  • SERVER_ADDR: IP address of the server. Since the server can have multiple ip addresses, this var will contain the ip associated with the hostname contained in the http request. If no hostname is present in the request will be used

Every field of the http request will be in a env var with the prefix: “HTTP_”, all the letters converted to uppercase and all the ”-” converted to “_”.

Command line

Command line isn't used, as defined in section 4.4.

cgi.txt · Last modified: 2010/05/31 16:03 by LtWorf
Recent changes RSS feed Valid XHTML 1.0 Valid CSS Driven by DokuWiki