[[cgi]]
 

This is an old revision of the document!


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.

Timeout

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

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

Standard input

Standard output

The script must send to its standard output an header terminating with \r\n\r\n, eventually followed by a page.
If no header information is found in the output, weborf will send to the client an error 500: Internal server error.

By default weborf will use code 200 in responses, but the script can override that using the Status header.

Weborf will split the headers from the content and generate the Content-Length header using the content's size.

Size

Maximum size of the output is defined by: MAXSCRIPTOUT+HEADBUF in configuration. It is not possible to send
to the client a generated page larger than this value.
A workaround is to generate the content and save it in a file, and then redirect the client to that file.

Standard error

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
  • REQUEST_METHOD: Can be POST or GET
  • 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 127.0.0.1

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.1230651212.txt.gz · Last modified: 2008/12/30 16:33 by LtWorf
 
Recent changes RSS feed Valid XHTML 1.0 Valid CSS Driven by DokuWiki