CGI programming

Author(s): The Ciao Development Team.

This module implements the predicates for CGI processes. It is based on translating the CGI environment to HTTP request terms (see http/http_server).

Usage and interface

Documentation on exports

Usage:cgi_read_request(Request)

Obtain a HTTP request from the CGI environment variables (for headers) and input stream data (for contents). This request can be processed with other predicates in the http_server libraries.

    PREDICATEmy_url/1
    my_url(URL)

    Unifies URL with the Uniform Resource Locator (WWW address) of this cgi executable.

    Usage:

    • Call and exit should be compatible with:
      (basic_props:string/1)URL is a string (a list of character codes).
    • The following properties should hold upon exit:
      (basic_props:string/1)URL is a string (a list of character codes).

    PREDICATEset_cookie/2
    set_cookie(Name,Value)

    Sets a cookie of name Name and value Value (it must be called before cgi_write_response/1)

    Usage:

    PREDICATEget_cookies/1
    get_cookies(Cookies)

    Unifies Cookies with a dictionary of attribute=value pairs of the active cookies for this URL. If the flag raw_form_values is on, values are always atoms even if they could be interpreted as numbers.

    Usage:

    • The following properties should hold at call time:
      (term_typing:var/1)Cookies is a free variable.
    • The following properties should hold upon exit:
      (http_forms:value_dict/1)Cookies is a dictionary of values. It is a list of pairs atom=constant.

    Usage:cgi_write_response(Response)

    Writes the CGI response (similar to a HTTP response but sent through stdout)

      Documentation on multifiles

      PREDICATEdefine_flag/3

      Usage:define_flag(Flag,FlagValues,Default)

      The predicate is multifile.

      Documentation on imports

      This module has the following direct dependencies: