response.js

/**
 * **Web-apps only**
 * 
 * Controls the response to the current HTTP request. Accessed
 * via the global variable `response`.  This variable is only available when the script
 * has been invoked by a HTTP request.
 * @namespace
 */
response = {

	/**
	 * Provides access to the headers of the response.
	 * The names of the fields of the returned object are those of the headers.
	 *
	 * Method:
	 *  - **add(name, value)** adds a header field with the given name and value.
	 * @type {Object}
	 */
	headers: {
		add: function (name, value) { }
	},

	/**
	 * Write the given text to the body of the response.
	 * 
	 * @method
	 * @param {String} text Text to write to the response.
	 */
	write: function (text) { },

	/**
	 * Apply the given data to the template in the given file and write
	 * the result to the response.  The template engine can also be accessed via the 
	 * {@link Templater#renderFile Templater.renderFile}
	 * method, which doesn't write to the response.
	 * 
	 * @method
	 * @param {String} templateFilePath Path to template file.
	 * @param {Object} data Object containing values to substitute into the template.
	 */
	writeUsingTemplateFile: function (templateFilePath, data) { },

	/**
	 * Apply the given data to the given template and write the result to the response.
	 * The template engine can also be accessed via the 
	 * {@link Templater#renderString Templater.renderString}
	 * method, which doesn't write to the response.
	 * 
	 * @method
	 * @param {String} template 
	 * @param {Object} data Object containing values to substitute into the template.
	 */
	writeUsingTemplateString: function (template, data) { },

	/**
	 * Path of file that the client will download.
	 * If this property is set to a value other than null then the response will be to have the client
	 * download the file with the given virtual file-system path.
	 * @type {String}
	 */
	downloadFile: null,

	/**
	 * File-name provided to the browser for the {@link downloadFile}.
	 * @type {String}
	 */
	downloadName: null,

	/**
	 * Should the client be forced to download the file (as opposed to possibly rendering it in the browser)?
	 * If this property is set to true then "content-disposition" field will be set in the HTTP header, which
	 * is usually interpreted by the browser to mean that the response will be saved to a file rather than
	 * rendered in the browser.
	 * @type {Boolean}
	 * @default false
	 */
	forceDownload: null,

	/**
	 * URL to redirect to.  If redirectUrl is set then the client will be redirected to the specified URL.
	 * @type {String}
	 */
	redirectUrl: null,

	/**
	 * Path of previous script that was executed. Scripts can be chained together by means of the nextScriptPath
	 * property. The value of previousScriptPath is the path of the previous script executed or null if no
	 * previous script was executed.
	 * @type {String}
	 */
	previousScriptPath: null,

	/**
	 * Path of script to execute next. Continue processing of the current request by executing the script at nextScriptPath.
	 * @type {String}
	 */
	nextScriptPath: null,

	/**
	 * HTML Content-Type of the response.
	 * @type {String}
	 */
	contentType: null,

	/**
	 * HTML status code (e.g. 200, 301, 401, 403, 500)
	 * @type {String}
	 */
	statusCode: null

}