Difference between revisions of "Server API"

From Fernseher
Jump to navigationJump to search
 
Line 4: Line 4:
*env: array of environment variables, including standard request headers and server information
*env: array of environment variables, including standard request headers and server information


Functions on the global server object:
Functions on the global server object. Low-level Apache/spidermonkey interface methods. Please use appropriate File and HTTPResponse methods wherever possible.
*logNotice(string|array of strings): function to log a notice (or a list of notices) to the server error log
*logNotice(string|array of strings): function to log a notice (or a list of notices) to the server error log
*logError(string|array of strings): function to log an error (or a list of errors) to the server error log
*logError(string|array of strings): function to log an error (or a list of errors) to the server error log
*runCmd(cmdstring): function execute a command on the server (with the httpd daemon's permissions!) execution of the script will wait until the cmd is finished, and will return the exit status of the command.
*status = runCmd(path, array of args): executes the given command on the server (with the httpd daemon's permissions!).  Script execution will block until finished, and will return the exit status. arguments will be escaped or quoted as necessary
*runCmd(cmd, array of args): same as above, but executes the given command with the arguments given in the arrayarguments will be escaped or quoted as necessary
*sendHeaders(): Push the headers to the client
*runCmd(File, array of args): same as above, but takes the given command from the File object passed in.
*sendString(string|array of strings): Print the strings specified to the client.
*sendFile(path): Print the strings specified to the client.
*setOutgoingHeader(key, value): sets the first outgoing header of the given keyname to value, and removes any extra headers of that name.  If key is content-type, content-encoding, or content-language, also sets the appropriate entry in the request_rec.
*addOutgoingHeader(key, value): adds the outgoing header of the given keyname to valueIf key is content-type, content-encoding, or content-language, also sets the appropriate entry in the request_rec.
*string = base64encode(string): encodes the string in base64
*string = base64decode(string): decodes the string from base64
*include(path): Runs the script specified by path in the current context

Latest revision as of 23:14, 22 January 2009

The server object is a global object representing the server interfaces for logging and environment and such in my Modjs implementation.

Data members on the global server object:

  • env: array of environment variables, including standard request headers and server information

Functions on the global server object. Low-level Apache/spidermonkey interface methods. Please use appropriate File and HTTPResponse methods wherever possible.

  • logNotice(string|array of strings): function to log a notice (or a list of notices) to the server error log
  • logError(string|array of strings): function to log an error (or a list of errors) to the server error log
  • status = runCmd(path, array of args): executes the given command on the server (with the httpd daemon's permissions!). Script execution will block until finished, and will return the exit status. arguments will be escaped or quoted as necessary
  • sendHeaders(): Push the headers to the client
  • sendString(string|array of strings): Print the strings specified to the client.
  • sendFile(path): Print the strings specified to the client.
  • setOutgoingHeader(key, value): sets the first outgoing header of the given keyname to value, and removes any extra headers of that name. If key is content-type, content-encoding, or content-language, also sets the appropriate entry in the request_rec.
  • addOutgoingHeader(key, value): adds the outgoing header of the given keyname to value. If key is content-type, content-encoding, or content-language, also sets the appropriate entry in the request_rec.
  • string = base64encode(string): encodes the string in base64
  • string = base64decode(string): decodes the string from base64
  • include(path): Runs the script specified by path in the current context